Big Integer
Properties
Returns a BigInteger whose value is the absolute value of this BigInteger.
Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit. For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. (Computes (ceil(log2(this < 0 ? -this : this+1))).)
Functions
Returns a BigInteger whose value is (this & val). (This method returns a negative BigInteger if and only if this and val are both negative.)
Returns a BigInteger whose value is (this & ~val). This method, which is equivalent to and(val.not()), is provided as a convenience for masking operations. (This method returns a negative BigInteger if and only if this is negative and other is positive.)
Returns a BigInteger whose value is equivalent to this BigInteger with the designated bit cleared. (Computes (this & ~(1<<n)).)
Compares this BigInteger with the specified BigInteger. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y)<op>0), where <op> is one of the six comparison operators.
Returns a BigInteger whose value is (this / val).
Returns an array of two BigIntegers containing (this / val) followed by (this % val).
Returns a BigInteger whose value is equivalent to this BigInteger with the designated bit flipped. (Computes (this ^ (1<<n)).)
Returns a BigInteger whose value is the greatest common divisor of absoluteValue(this) and absoluteValue(val). Returns 0 if this == 0 && val == 0.
Returns true if this BigInteger is probably prime, false if it's definitely composite. If certainty is 0, true is returned.
Returns the maximum of this BigInteger and other.
Returns the minimum of this BigInteger and other.
Returns a BigInteger whose value is (this - val).
Returns a BigInteger whose value is (this-1 rem m).
Returns a BigInteger whose value is (this<sup>exponent</sup> rem m). (Unlike pow, this method permits negative exponents.)
Returns the first integer greater than this BigInteger that is probably prime. The probability that the number returned by this method is composite does not exceed 2-100. This method will never skip over a prime when searching: if it returns p, there is no prime q such that this < q < p.
Returns a BigInteger whose value is (~this). (This method returns a negative value if and only if this BigInteger is non-negative.)
Returns a BigInteger whose value is (this | val). (This method returns a negative BigInteger if and only if either this or val is negative.)
Returns a BigInteger whose value is (this + val).
Returns a BigInteger whose value is (this<sup>exponent</sup>). Note that exponent is an integer rather than a BigInteger.
Returns a BigInteger whose value is (this rem m). This method differs from remainder in that it always returns a non-negative BigInteger.
Returns a BigInteger whose value is (this % val).
Returns a BigInteger whose value is equivalent to this BigInteger with the designated bit set. (Computes (this | (1<<n)).)
Returns a BigInteger whose value is (this << n). The shift distance, n, may be negative, in which case this method performs a right shift. (Computes floor(this * 2<sup>n</sup>).)
Returns a BigInteger whose value is (this >> n). Sign extension is performed. The shift distance, n, may be negative, in which case this method performs a left shift. (Computes floor(this / 2<sup>n</sup>).)
Returns the integer square root of this BigInteger. The integer square root of the corresponding mathematical integer n is the largest mathematical integer s such that s*s <= n. It is equal to the value of floor(sqrt(n)), where sqrt(n) denotes the real square root of n treated as a real. Note that the integer square root will be less than the real square root if the latter is not representable as an integral value.
Returns an array of two BigIntegers containing the integer square root s of this and its remainder this - s*s, respectively.
Returns a BigInteger whose value is (this * val).
Returns a byte array containing the two's-complement representation of this BigInteger. The byte array will be in big-endian byte-order: the most significant byte is in the zeroth element. The array will contain the minimum number of bytes required to represent this BigInteger, including at least one sign bit, which is (ceil((this.bitLength() + 1)/8)). (This representation is compatible with the byte array constructor.)
Converts this BigInteger to a byte, checking for lost information. If the value of this BigInteger is out of the range of the byte type, then an ArithmeticException is thrown.
Converts this BigInteger to an int. This conversion is analogous to a narrowing primitive conversion from long to int as defined in The Java Language Specification: if this BigInteger is too big to fit in an int, only the low-order 32 bits are returned. Note that this conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign.
Converts this BigInteger to an int, checking for lost information. If the value of this BigInteger is out of the range of the int type, then an ArithmeticException is thrown.
Converts this BigInteger to a long. This conversion is analogous to a narrowing primitive conversion from long to int as defined in The Java Language Specification: if this BigInteger is too big to fit in a long, only the low-order 64 bits are returned. Note that this conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign.
Converts this BigInteger to a long, checking for lost information. If the value of this BigInteger is out of the range of the long type, then an ArithmeticException is thrown.
Converts this BigInteger to a short, checking for lost information. If the value of this BigInteger is out of the range of the short type, then an ArithmeticException is thrown.
Returns the decimal String representation of this BigInteger. The digit-to-character mapping provided by Character.forDigit is used, and a subtract sign is prepended if appropriate. (This representation is compatible with the string constructor, and allows for String concatenation with Java's + operator.)
Returns the String representation of this BigInteger in the given radix. If the radix is outside the range from CHAR_MIN_RADIX to CHAR_MAX_RADIX inclusive, it will default to 10 (as is the case for Int.toString). The digit-to-character mapping provided by Character.forDigit is used, and a subtract sign is prepended if appropriate. (This representation is compatible with the String constructor.)
Returns a BigInteger whose value is (-this).
Returns a BigInteger whose value is (this ^ val). (This method returns a negative BigInteger if and only if exactly one of this and val are negative.)