/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a random non-negative {@code BigInteger} instance in the range * {@code [0, pow(2, numBits)-1]}. * * @param numBits maximum length of the new {@code BigInteger} in bits. * @param random is the random number generator to be used. * @throws IllegalArgumentException if {@code numBits} < 0. */ public BigInteger(int numBits, Random random) { if (numBits < 0) { throw new IllegalArgumentException("numBits < 0: " + numBits); } if (numBits == 0) { setJavaRepresentation(0, 1, new int[] { 0 }); } else { int sign = 1; int numberLength = (numBits + 31) >> 5; int[] digits = new int[numberLength]; for (int i = 0; i < numberLength; i++) { digits[i] = random.nextInt(); } // Clear any extra bits. digits[numberLength - 1] >>>= (-numBits) & 31; setJavaRepresentation(sign, numberLength, digits); } javaIsValid = true; }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
bi.setJavaRepresentation(sign, numberLength, digits);
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a number without creating new space. This construct should be * used only if the three fields of representation are known. * * @param sign the sign of the number. * @param numberLength the length of the internal array. * @param digits a reference of some array created before. */ BigInteger(int sign, int numberLength, int[] digits) { setJavaRepresentation(sign, numberLength, digits); }
/** * Constructs a random non-negative {@code BigInteger} instance in the range * {@code [0, pow(2, numBits)-1]}. * * @param numBits maximum length of the new {@code BigInteger} in bits. * @param random is the random number generator to be used. * @throws IllegalArgumentException if {@code numBits} < 0. */ public BigInteger(int numBits, Random random) { if (numBits < 0) { throw new IllegalArgumentException("numBits < 0: " + numBits); } if (numBits == 0) { setJavaRepresentation(0, 1, new int[] { 0 }); } else { int sign = 1; int numberLength = (numBits + 31) >> 5; int[] digits = new int[numberLength]; for (int i = 0; i < numberLength; i++) { digits[i] = random.nextInt(); } // Clear any extra bits. digits[numberLength - 1] >>>= (-numBits) & 31; setJavaRepresentation(sign, numberLength, digits); } javaIsValid = true; }
/** * Constructs a random non-negative {@code BigInteger} instance in the range * {@code [0, pow(2, numBits)-1]}. * * @param numBits maximum length of the new {@code BigInteger} in bits. * @param random is the random number generator to be used. * @throws IllegalArgumentException if {@code numBits} < 0. */ public BigInteger(int numBits, Random random) { if (numBits < 0) { throw new IllegalArgumentException("numBits < 0: " + numBits); } if (numBits == 0) { setJavaRepresentation(0, 1, new int[] { 0 }); } else { int sign = 1; int numberLength = (numBits + 31) >> 5; int[] digits = new int[numberLength]; for (int i = 0; i < numberLength; i++) { digits[i] = random.nextInt(); } // Clear any extra bits. digits[numberLength - 1] >>>= (-numBits) & 31; setJavaRepresentation(sign, numberLength, digits); } javaIsValid = true; }
/** * Constructs a random non-negative {@code BigInteger} instance in the range * {@code [0, pow(2, numBits)-1]}. * * @param numBits maximum length of the new {@code BigInteger} in bits. * @param random is the random number generator to be used. * @throws IllegalArgumentException if {@code numBits} < 0. */ public BigInteger(int numBits, Random random) { if (numBits < 0) { throw new IllegalArgumentException("numBits < 0: " + numBits); } if (numBits == 0) { setJavaRepresentation(0, 1, new int[] { 0 }); } else { int sign = 1; int numberLength = (numBits + 31) >> 5; int[] digits = new int[numberLength]; for (int i = 0; i < numberLength; i++) { digits[i] = random.nextInt(); } // Clear any extra bits. digits[numberLength - 1] >>>= (-numBits) & 31; setJavaRepresentation(sign, numberLength, digits); } javaIsValid = true; }
/** * Constructs a random non-negative {@code BigInteger} instance in the range * {@code [0, pow(2, numBits)-1]}. * * @param numBits maximum length of the new {@code BigInteger} in bits. * @param random is the random number generator to be used. * @throws IllegalArgumentException if {@code numBits} < 0. */ public BigInteger(int numBits, Random random) { if (numBits < 0) { throw new IllegalArgumentException("numBits < 0: " + numBits); } if (numBits == 0) { setJavaRepresentation(0, 1, new int[] { 0 }); } else { int sign = 1; int numberLength = (numBits + 31) >> 5; int[] digits = new int[numberLength]; for (int i = 0; i < numberLength; i++) { digits[i] = random.nextInt(); } // Clear any extra bits. digits[numberLength - 1] >>>= (-numBits) & 31; setJavaRepresentation(sign, numberLength, digits); } javaIsValid = true; }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }
void prepareJavaRepresentation() { if (javaIsValid) { return; } synchronized (this) { if (javaIsValid) { return; } int sign = bigInt.sign(); int[] digits = (sign != 0) ? bigInt.littleEndianIntsMagnitude() : new int[] { 0 }; setJavaRepresentation(sign, digits.length, digits); } }