BigInteger
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | intLen
The number of ints of the value array that are currently used to hold the magnitude of this MutableBigInteger. |
| pack-priv static final int | KNUTH_POW2_THRESH_LEN
The minimum |
| pack-priv static final int | KNUTH_POW2_THRESH_ZEROS
The minimum number of trailing zero ints for cancelling powers of two before dividing. |
| pack-priv int | offset
The offset into the value array where the magnitude of this MutableBigInteger begins. |
| pack-priv static final MutableBigInteger | ONE
MutableBigInteger with one element value array with the value 1. |
| pack-priv int[] | value
Holds the magnitude of this MutableBigInteger in big endian order. |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | MutableBigInteger(int val)
Construct a new MutableBigInteger with a magnitude specified by the int val. |
| pack-priv | MutableBigInteger(long val)
Construct a new MutableBigInteger with a magnitude specified by the long val. |
| pack-priv | MutableBigInteger(int[] val)
Construct a new MutableBigInteger with the specified value array up to the length of the array supplied. |
| pack-priv | MutableBigInteger(BigInteger b)
Construct a new MutableBigInteger with a magnitude equal to the specified BigInteger. |
| pack-priv | MutableBigInteger(MutableBigInteger val)
Construct a new MutableBigInteger with a magnitude equal to the specified MutableBigInteger. |
| Modifier and Type | Method and Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pack-priv void | add(MutableBigInteger addend)
Adds the contents of two MutableBigInteger objects.The result is placed within this MutableBigInteger. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | addDisjoint(MutableBigInteger addend, int n)
Like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private MutableBigInteger | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv static int | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv long | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv final int | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv final int | compareHalf(MutableBigInteger b)
Compare this against half of a MutableBigInteger object (Needed for remainder tests). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int | compareShifted(MutableBigInteger b, int ints)
Returns a value equal to what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | copyValue(MutableBigInteger src)
Sets this MutableBigInteger's value array to a copy of the specified array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int | difference(MutableBigInteger b)
Subtracts the smaller of a and b from the larger and places the result into the larger. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | divide(MutableBigInteger b, MutableBigInteger quotient)
Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv long | Returns: the remainder of the division will be 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private MutableBigInteger | Returns: this%ba positive number such that b, MutableBigInteger b.bitLength() is evenoutput parameter for quotient)this/bThis method implements algorithm 1 from pg. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private MutableBigInteger | Returns: this%boutput parameter for quotient)this/bThis method implements algorithm 2 from pg. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | Returns: the remainderthe divisor b, MutableBigInteger output parameter for quotient)this/bComputes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | divideKnuth(MutableBigInteger b, MutableBigInteger quotient, boolean needRemainder)
Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private MutableBigInteger | divideLongMagnitude(long ldivisor, MutableBigInteger quotient)
Divide this MutableBigInteger by the divisor represented by positive long value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private MutableBigInteger | divideMagnitude(MutableBigInteger div, MutableBigInteger quotient, boolean needRemainder)
Divide this MutableBigInteger by the divisor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv int | Returns: the remainder of the division is returned.This method is used for division of an n word dividend by a one word divisor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final void | ensureCapacity(int len)
If this MutableBigInteger cannot hold len words, increase the size of the value array to len words. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv MutableBigInteger | euclidModInverse(int k)
Uses the extended Euclidean algorithm to compute the modInverse of base mod a modulus that is a power of 2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pack-priv static MutableBigInteger | fixup(MutableBigInteger c, MutableBigInteger p, int k) The Fixup Algorithm Calculates X such that X = C * 2^(-k) (mod P) Assumes C
private MutableBigInteger | getBlock(int
the block index index, int the total number of blocks in numBlocks, int this numberlength of one block in units of 32 bits blockLength)Returns a private MutableBigInteger | Returns: aMutableBigInteger obtained by taking blockLen ints from
this number, ending at blockIndex*blockLen (exclusive).the block index, starting from the lowest blockIndex, int the logical length of the input value in units of 32 bits len, int the length of the block in units of 32 bits blockLen)Returns a private final int |
| private final long | getLong(int index)
Return a long which is equal to the unsigned value of the int in use in this MutableBigInteger at the specified index. private BigInteger |
| private final int |
| private int[] |
| pack-priv MutableBigInteger |
| private void |
| pack-priv static int |
| pack-priv static long |
| pack-priv boolean |
| pack-priv boolean |
| pack-priv boolean |
| pack-priv boolean |
| pack-priv boolean |
| private void |
| pack-priv void |
| private MutableBigInteger | modInverse(MutableBigInteger mod)
Calculate the multiplicative inverse of this modulo mod, where the mod argument is odd. pack-priv static MutableBigInteger | modInverseBP2(MutableBigInteger mod, int k)
Calculate the multiplicative inverse of 2^k mod mod, where mod is odd. pack-priv MutableBigInteger |
| pack-priv void |
| private int |
| private int | mulsubBorrow(int[] q, int[] a, int x, int len, int offset)
The method is the same as mulsun, except the fact that q array is not updated, the only result of the method is borrow flag. private int |
| pack-priv void | multiply(MutableBigInteger y, MutableBigInteger z)
Multiply the contents of two MutableBigInteger objects. pack-priv MutableBigInteger |
| private static void | newtonRecurrenceRootn(MutableBigInteger x, MutableBigInteger s, int n, BigInteger sToN1)
Computes pack-priv final void | normalize()
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. private void | ones(int
number of ints in the n)value arrayMakes this number an private void |
| private void | primitiveLeftShift(int n, int[] result, int resFrom)
Left shift this MutableBigInteger n bits, where n is less than 32, placing the result in the specified array. private void |
| private void | primitiveRightShift(int n, int[] result, int resFrom)
Right shift this MutableBigInteger n bits, where n is less than 32, placing the result in the specified array. pack-priv void |
| pack-priv void |
| private static double |
| pack-priv MutableBigInteger[] | Returns: the integernth root of this and the remainderthe root degree n)Calculate the integer pack-priv void |
| pack-priv void |
| pack-priv void |
| pack-priv void |
| pack-priv void |
| pack-priv void |
| pack-priv MutableBigInteger[] | Returns: the integer square root ofthis and the remainder if neededCalculate the integer square root private MutableBigInteger[] | sqrtRemKaratsuba(int len, boolean needRemainder)
Assumes pack-priv int | subtract(MutableBigInteger b)
Subtracts the smaller of this and b from the larger and places the result into this MutableBigInteger. pack-priv BigDecimal | toBigDecimal(int sign, int scale)
Convert this MutableBigInteger to BigDecimal object with the specified sign and scale. pack-priv BigInteger |
| pack-priv BigInteger |
| pack-priv long | toCompactValue(int sign)
This is for internal use in converting from a MutableBigInteger object into a long value given a specified sign. pack-priv int[] | toIntArray()
Convert this MutableBigInteger into an int array with no leading zeros, of a length that is equal to this MutableBigInteger's intLen. private long |
| public String | toString()
Overrides java. Returns a String representation of this MutableBigInteger in radix 10. private boolean |
| private static long |
| |
| intLen | back to summary |
|---|---|
| pack-priv int intLen 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. | |
| KNUTH_POW2_THRESH_LEN | back to summary |
|---|---|
| pack-priv static final int KNUTH_POW2_THRESH_LEN The minimum | |
| KNUTH_POW2_THRESH_ZEROS | back to summary |
|---|---|
| pack-priv static final int KNUTH_POW2_THRESH_ZEROS 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, | |
| offset | back to summary |
|---|---|
| pack-priv int offset The offset into the value array where the magnitude of this MutableBigInteger begins. | |
| ONE | back to summary |
|---|---|
| pack-priv static final MutableBigInteger ONE 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. | |
| value | back to summary |
|---|---|
| pack-priv int[] value 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. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger() The default constructor. An empty MutableBigInteger is created with a one word capacity. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger(int val) Construct a new MutableBigInteger with a magnitude specified by the int val. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger(long val) Construct a new MutableBigInteger with a magnitude specified by the long val. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger(int[] val) Construct a new MutableBigInteger with the specified value array up to the length of the array supplied. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger(BigInteger b) Construct a new MutableBigInteger with a magnitude equal to the specified BigInteger. | |
| MutableBigInteger | back to summary |
|---|---|
| pack-priv MutableBigInteger(MutableBigInteger val) Construct a new MutableBigInteger with a magnitude equal to the specified MutableBigInteger. | |
| add | back to summary |
|---|---|
| pack-priv void add(MutableBigInteger addend) Adds the contents of two MutableBigInteger objects.The result is placed within this MutableBigInteger. The contents of the addend are not changed. | |
| addDisjoint | back to summary |
|---|---|
| pack-priv void addDisjoint(MutableBigInteger addend, int n) Like | |
| addLower | back to summary |
|---|---|
| pack-priv void addLower(MutableBigInteger addend, int n) Adds the low | |
| addShifted | back to summary |
|---|---|
| pack-priv void addShifted(MutableBigInteger addend, int n) Adds the value of | |
| binaryGCD | back to summary |
|---|---|
| private MutableBigInteger binaryGCD(MutableBigInteger v) Calculate GCD of this and v. Assumes that this and v are not zero. | |
| binaryGcd | back to summary |
|---|---|
| pack-priv static int binaryGcd(int a, int b) Calculate GCD of a and b interpreted as unsigned integers. | |
| bitLength | back to summary |
|---|---|
pack-priv long bitLength()
| |
| clear | back to summary |
|---|---|
| pack-priv void clear() Clear out a MutableBigInteger for reuse. | |
| compare | back to summary |
|---|---|
| pack-priv final int compare(MutableBigInteger b) Compare the magnitude of two MutableBigIntegers. Returns -1, 0 or 1
as this MutableBigInteger is numerically less than, equal to, or
greater than | |
| compareHalf | back to summary |
|---|---|
| pack-priv final int compareHalf(MutableBigInteger b) Compare this against half of a MutableBigInteger object (Needed for remainder tests). Assumes no leading unnecessary zeros, which holds for results from divide(). | |
| compareShifted | back to summary |
|---|---|
| private int compareShifted(MutableBigInteger b, int ints) Returns a value equal to what | |
| copyValue | back to summary |
|---|---|
| pack-priv void copyValue(MutableBigInteger src) Sets this MutableBigInteger's value array to a copy of the specified array. The intLen is set to the length of the new array. | |
| copyValue | back to summary |
|---|---|
| pack-priv void copyValue(int[] val) Sets this MutableBigInteger's value array to a copy of the specified array. The intLen is set to the length of the specified array. | |
| difference | back to summary |
|---|---|
| private int difference(MutableBigInteger b) Subtracts the smaller of a and b from the larger and places the result into the larger. Returns 1 if the answer is in a, -1 if in b, 0 if no operation was performed. | |
| divadd | back to summary |
|---|---|
| private int divadd(int[] a, int[] result, int offset) A primitive used for division. This method adds in one multiple of the divisor a back to the dividend result at a specified offset. It is used when qhat was estimated too large, and must be adjusted. | |
| divaddLong | back to summary |
|---|---|
| private int divaddLong(int dh, int dl, int[] result, int offset) A primitive used for division by long. Specialized version of the method divadd. dh is a high part of the divisor, dl is a low part | |
| divide | back to summary |
|---|---|
| pack-priv MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient) Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned. | |
| divide | back to summary |
|---|---|
| pack-priv MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient, boolean needRemainder) | |
| divide | back to summary |
|---|---|
| pack-priv long divide(long v, MutableBigInteger quotient) Internally used to calculate the quotient of this div v and places the quotient in the provided MutableBigInteger object and the remainder is returned.
| |
| divide2n1n | back to summary |
|---|---|
| private MutableBigInteger divide2n1n(MutableBigInteger b, MutableBigInteger quotient) This method implements algorithm 1 from pg. 4 of the Burnikel-Ziegler paper.
It divides a 2n-digit number by a n-digit number.
| |
| divide3n2n | back to summary |
|---|---|
| private MutableBigInteger divide3n2n(MutableBigInteger b, MutableBigInteger quotient) This method implements algorithm 2 from pg. 5 of the Burnikel-Ziegler paper.
It divides a 3n-digit number by a 2n-digit number.
| |
| divideAndRemainderBurnikelZiegler | back to summary |
|---|---|
| pack-priv MutableBigInteger divideAndRemainderBurnikelZiegler(MutableBigInteger b, MutableBigInteger quotient) Computes
| |
| divideKnuth | back to summary |
|---|---|
| pack-priv MutableBigInteger divideKnuth(MutableBigInteger b, MutableBigInteger quotient) | |
| divideKnuth | back to summary |
|---|---|
| pack-priv MutableBigInteger divideKnuth(MutableBigInteger b, MutableBigInteger quotient, boolean needRemainder) Calculates the quotient of this div b and places the quotient in the provided MutableBigInteger objects and the remainder object is returned. Uses Algorithm D from Knuth TAOCP Vol. 2, 3rd edition, section 4.3.1. Many optimizations to that algorithm have been adapted from the Colin Plumb C library. It special cases one word divisors for speed. The content of b is not changed. | |
| divideLongMagnitude | back to summary |
|---|---|
| private MutableBigInteger divideLongMagnitude(long ldivisor, MutableBigInteger quotient) Divide this MutableBigInteger by the divisor represented by positive long value. The quotient will be placed into the provided quotient object & the remainder object is returned. | |
| divideMagnitude | back to summary |
|---|---|
| private MutableBigInteger divideMagnitude(MutableBigInteger div, MutableBigInteger quotient, boolean needRemainder) Divide this MutableBigInteger by the divisor. The quotient will be placed into the provided quotient object & the remainder object is returned. | |
| divideOneWord | back to summary |
|---|---|
| pack-priv int divideOneWord(int divisor, MutableBigInteger quotient) 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.
| |
| ensureCapacity | back to summary |
|---|---|
| private final void ensureCapacity(int len) If this MutableBigInteger cannot hold len words, increase the size of the value array to len words. | |
| euclidModInverse | back to summary |
|---|---|
| pack-priv MutableBigInteger euclidModInverse(int k) 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. | |
| fixup | back to summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pack-priv static MutableBigInteger fixup(MutableBigInteger c, MutableBigInteger p, int k) The Fixup Algorithm Calculates X such that X = C * 2^(-k) (mod P) Assumes C
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||