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 a magnitude equal to the specified MutableBigInteger.
Signed addition built upon unsigned add and subtract.
Signed addition built upon unsigned add and subtract.
Signed subtraction built upon unsigned add and subtract.
Signed subtraction built upon unsigned add and subtract.
Print out the first intLen ints of this MutableBigInteger's value array starting at offset.
The sign of this MutableBigInteger.
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.
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.
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.
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
Clear out a MutableBigInteger for reuse.
Set a MutableBigInteger to zero, removing its offset.
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().
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.
Convert this MutableBigInteger into an int array with no leading zeros, of a length that is equal to this MutableBigInteger's intLen.
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.
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.
Returns true iff this MutableBigInteger has a value of one.
Returns true iff this MutableBigInteger has a value of zero.
Returns true iff this MutableBigInteger is even.
Returns true iff this MutableBigInteger is odd.
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 a string representation of this MutableBigInteger in radix 10.
Like {@link #rightShift(int)} but {@code n} can be greater than the length of the number.
Right shift this MutableBigInteger n bits. The MutableBigInteger is left in normal form.
Like {@link #leftShift(int)} but {@code n} can be zero.
Left shift this MutableBigInteger n bits.
Adds the contents of two MutableBigInteger objects.The result is placed within this MutableBigInteger. The contents of the addend are not changed.
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}.
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}.
Subtracts the smaller of this and b from the larger and places the result into this MutableBigInteger.
Multiply the contents of two MutableBigInteger objects. The result is placed into MutableBigInteger z. The contents of y are not changed.
Multiply the contents of this MutableBigInteger by the word y. The result is placed into z.
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.
Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned.
@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.
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 BigInteger#bitLength()
Internally used to calculate the quotient of this div v and places the quotient in the provided MutableBigInteger object and the remainder is returned.
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.
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.
Calculate GCD of this and b. This and b are changed by the computation.
Calculate GCD of a and b interpreted as unsigned integers.
Returns the modInverse of this mod p. This and p are not affected by the operation.
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.
The Fixup Algorithm Calculates X such that X = C * 2^(-k) (mod P) Assumes C<P and P is odd.
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.
A class used to represent multiprecision integers that makes efficient use of allocated space by allowing a number to occupy only part of an array so that the arrays do not have to be reallocated as often. When performing an operation with many iterations the array used to hold a number is only increased when necessary and does not have to be the same size as the number it represents. A mutable number allows calculations to occur on the same number without having to create a new number for every step of the calculation as occurs with BigIntegers.
Note that SignedMutableBigIntegers only support signed addition and subtraction. All other operations occur as with MutableBigIntegers.
@see BigInteger @author Michael McCloskey