Skip to content

Constructors BigInteger and BigDecimal used to wrap primitives should never be used. #3627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/com/thealgorithms/ciphers/AES.java
Original file line number Diff line number Diff line change
Expand Up @@ -2438,16 +2438,16 @@ public static BigInteger scheduleCore(BigInteger t, int rconCounter) {
public static BigInteger[] keyExpansion(BigInteger initialKey) {
BigInteger[] roundKeys = {
initialKey,
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
new BigInteger("0"),
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
BigInteger.ZERO,
};

// initialize rcon iteration
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/ciphers/RSA.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public synchronized void generateKeys(int bits) {
publicKey = BigInteger.valueOf(3L);

while (m.gcd(publicKey).intValue() > 1) {
publicKey = publicKey.add(BigInteger.valueOf(2L));
publicKey = publicKey.add(BigInteger.TWO);
}

privateKey = publicKey.modInverse(m);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/thealgorithms/maths/KaprekarNumbers.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class KaprekarNumbers {
digits and sum of these parts is equal to the original number. */

// Provides a list of kaprekarNumber in a range
public static ArrayList<Long> kaprekarNumberInRange(long start, long end)
public static List<Long> kaprekarNumberInRange(long start, long end)
throws Exception {
long n = end - start;
if (n < 0) throw new Exception("Invalid range");
Expand All @@ -26,12 +26,12 @@ public static ArrayList<Long> kaprekarNumberInRange(long start, long end)
// Checks whether a given number is Kaprekar Number or not
public static boolean isKaprekarNumber(long num) {
String number = Long.toString(num);
BigInteger originalNumber = new BigInteger(number);
BigInteger originalNumber = BigInteger.valueOf(num);
BigInteger numberSquared = originalNumber.multiply(originalNumber);
if (number.length() == numberSquared.toString().length()) {
return number.equals(numberSquared.toString());
} else {
BigInteger leftDigits1 = new BigInteger("0");
BigInteger leftDigits1 = BigInteger.ZERO;
BigInteger leftDigits2;
if (numberSquared.toString().contains("0")) {
leftDigits1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static org.junit.jupiter.api.Assertions.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;

public class KaprekarNumbersTest {
Expand Down Expand Up @@ -50,7 +51,7 @@ void testFor98() {
@Test
void testForRangeOfNumber() {
try {
ArrayList<Long> rangedNumbers = KaprekarNumbers.kaprekarNumberInRange(
List<Long> rangedNumbers = KaprekarNumbers.kaprekarNumberInRange(
1,
100000
);
Expand Down