Big Integer
Translates a byte sub-array containing the two's-complement binary representation of a BigInteger into a BigInteger. The sub-array is specified via an offset into the array and a length. The sub-array is assumed to be in big-endian byte-order: the most significant byte is the element at index off. The val array is assumed to be unchanged for the duration of the constructor call.
An IndexOutOfBoundsException is thrown if the length of the array val is non-zero and either off is negative, len is negative, or off+len is greater than the length of val.
Since
9
Parameters
byte array containing a sub-array which is the big-endian two's-complement binary representation of a BigInteger.
the start offset of the binary representation.
the number of bytes to use.
Throws
val is zero bytes long.
if the provided array offset and length would cause an index into the byte array to be negative or greater than or equal to the array length.
Translates the sign-magnitude representation of a BigInteger into a BigInteger. The sign is represented as an integer _signum value: -1 for negative, 0 for zero, or 1 for positive. The magnitude is a sub-array of a byte array in big-endian byte-order: the most significant byte is the element at index off. A zero value of the length len is permissible, and will result in a BigInteger value of 0, whether _signum is -1, 0 or 1. The magnitude array is assumed to be unchanged for the duration of the constructor call.
An IndexOutOfBoundsException is thrown if the length of the array magnitude is non-zero and either off is negative, len is negative, or off+len is greater than the length of magnitude.
Since
9
Parameters
_signum of the number (-1 for negative, 0 for zero, 1 for positive).
big-endian binary representation of the magnitude of the number.
the start offset of the binary representation.
the number of bytes to use.
Throws
_signum is not one of the three legal values (-1, 0, and 1), or _signum is 0 and magnitude contains one or more non-zero bytes.
if the provided array offset and length would cause an index into the byte array to be negative or greater than or equal to the array length.
Translates the String representation of a BigInteger in the specified radix into a BigInteger. The String representation consists of an optional subtract or plus sign followed by a sequence of one or more digits in the specified radix. The character-to-digit mapping is provided by Character.digit. The String may not contain any extraneous characters (whitespace, for example).
See also
Parameters
String representation of BigInteger.
radix to be used in interpreting val.
Throws
val is not a valid representation of a BigInteger in the specified radix, or radix is outside the range from CHAR_MIN_RADIX to CHAR_MAX_RADIX, inclusive.
Constructs a randomly generated BigInteger, uniformly distributed over the range 0 to (2<sup>numBits</sup> - 1), inclusive. The uniformity of the distribution assumes that a fair source of random bits is provided in rnd. Note that this constructor always constructs a non-negative BigInteger.
See also
.bitLength
Parameters
maximum bitLength of the new BigInteger.
source of randomness to be used in computing the new BigInteger.
Throws
numBits is negative.
Constructs a randomly generated positive BigInteger that is probably prime, with the specified bitLength.
See also
.bitLength
Parameters
bitLength of the returned BigInteger.
a measure of the uncertainty that the caller is willing to tolerate. The probability that the new BigInteger represents a prime number will exceed (1 - 1/2<sup>certainty</sup>). The execution time of this constructor is proportional to the value of this parameter.
source of random bits used to select candidates to be tested for primality.
Throws
bitLength < 2 or bitLength is too large.