The default constructor. An empty MutableBigInteger is created with a one word capacity.
Construct a new MutableBigInteger with a magnitude specified by the int val.
Construct a new MutableBigInteger with the specified value array up to the length of the array supplied.
Construct a new MutableBigInteger with a magnitude equal to the specified BigInteger.
Construct a new MutableBigInteger with a magnitude equal to the specified MutableBigInteger.
Adds the contents of two MutableBigInteger objects.The result is placed within this MutableBigInteger. The contents of the addend are not changed.
Like {@link #addShifted(MutableBigInteger, int)} but {@code this.intLen} must not be greater than {@code n}. In other words, concatenates {@code this} and {@code addend}.
Adds the low {@code n} ints of {@code addend}.
Adds the value of {@code addend} shifted {@code n} ints to the left. Has the same effect as {@code addend.leftShift(32*ints); add(addend);} but doesn't change the value of {@code addend}.
@see BigInteger#bitLength()
Clear out a MutableBigInteger for reuse.
Compare the magnitude of two MutableBigIntegers. Returns -1, 0 or 1 as this MutableBigInteger is numerically less than, equal to, or greater than {@code b}.
Compare this against half of a MutableBigInteger object (Needed for remainder tests). Assumes no leading unnecessary zeros, which holds for results from divide().
Sets this MutableBigInteger's value array to a copy of the specified array. The intLen is set to the length of the new array.
Sets this MutableBigInteger's value array to a copy of the specified array. The intLen is set to the length of the specified array.
Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned.
Internally used to calculate the quotient of this div v and places the quotient in the provided MutableBigInteger object and the remainder is returned.
Computes {@code this/b} and {@code this%b} using the <a href="http://cr.yp.to/bib/1998/burnikel.ps"> Burnikel-Ziegler algorithm</a>. This method implements algorithm 3 from pg. 9 of the Burnikel-Ziegler paper. The parameter beta was chosen to b 2<sup>32</sup> so almost all shifts are multiples of 32 bits.<br/> {@code this} and {@code b} must be nonnegative. @param b the divisor @param quotient output parameter for {@code this/b} @return the remainder
@see #divideKnuth(MutableBigInteger, MutableBigInteger, bool)
Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned.
This method is used for division of an n word dividend by a one word divisor. The quotient is placed into quotient. The one word divisor is specified by divisor.
Uses the extended Euclidean algorithm to compute the modInverse of base mod a modulus that is a power of 2. The modulus is 2^k.
Calculate GCD of this and b. This and b are changed by the computation.
Returns true iff this MutableBigInteger is even.
Returns true iff this MutableBigInteger is in normal form. A MutableBigInteger is in normal form if it has no leading zeros after the offset, and intLen + offset <= cast(int)value.length.
Returns true iff this MutableBigInteger is odd.
Returns true iff this MutableBigInteger has a value of one.
Returns true iff this MutableBigInteger has a value of zero.
Left shift this MutableBigInteger n bits.
Multiply the contents of this MutableBigInteger by the word y. The result is placed into z.
Multiply the contents of two MutableBigInteger objects. The result is placed into MutableBigInteger z. The contents of y are not changed.
Returns the modInverse of this mod p. This and p are not affected by the operation.
Ensure that the MutableBigInteger is in normal form, specifically making sure that there are no leading zeros, and that if the magnitude is zero, then intLen is zero.
Set a MutableBigInteger to zero, removing its offset.
Right shift this MutableBigInteger n bits. The MutableBigInteger is left in normal form.
Like {@link #leftShift(int)} but {@code n} can be zero.
Like {@link #rightShift(int)} but {@code n} can be greater than the length of the number.
Sets the int at index+offset in this MutableBigInteger to val. This does not get inlined on all platforms so it is not used as often as originally intended.
Sets this MutableBigInteger's value array to the specified array. The intLen is set to the specified length.
Calculate the integer square root {@code floor(sqrt(this))} where {@code sqrt(.)} denotes the mathematical square root. The contents of {@code this} are <b>not</b> changed. The value of {@code this} is assumed to be non-negative.
Subtracts the smaller of this and b from the larger and places the result into this MutableBigInteger.
Convert this MutableBigInteger to a BigInteger object.
Converts this number to a nonnegative {@code BigInteger}.
This is for internal use in converting from a MutableBigInteger object into a long value given a specified sign. returns INFLATED if value is not fit into long
Convert this MutableBigInteger into an int array with no leading zeros, of a length that is equal to this MutableBigInteger's intLen.
Returns a string representation of this MutableBigInteger in radix 10.
Calculate GCD of a and b interpreted as unsigned integers.
This method divides a long quantity by an int to estimate qhat for two multi precision numbers. It is used when the signed value of n is less than zero. Returns long value where high 32 bits contain remainder value and low 32 bits contain quotient value.
The Fixup Algorithm Calculates X such that X = C * 2^(-k) (mod P) Assumes C<P and P is odd.
Returns the multiplicative inverse of val mod 2^32. Assumes val is odd.
Returns the multiplicative inverse of val mod 2^64. Assumes val is odd.
Calculate the multiplicative inverse of 2^k mod mod, where mod is odd.
MutableBigInteger with one element value array with the value 1. Used by BigDecimal divideAndRound to increment the quotient. Use this constant only when the method is not going to modify this object.
The minimum {@code intLen} for cancelling powers of two before dividing. If the number of ints is less than this threshold, {@code divideKnuth} does not eliminate common powers of two from the dividend and divisor.
The minimum number of trailing zero ints for cancelling powers of two before dividing. If the dividend and divisor don't share at least this many zero ints at the end, {@code divideKnuth} does not eliminate common powers of two from the dividend and divisor.
The number of ints of the value array that are currently used to hold the magnitude of this MutableBigInteger. The magnitude starts at an offset and offset + intLen may be less than value.length.
The offset into the value array where the magnitude of this MutableBigInteger begins.
Holds the magnitude of this MutableBigInteger in big endian order. The magnitude may start at an offset into the value array, and it may end before the length of the value array.