Save This Page
Home » openjdk-7 » java » math » [javadoc | source]
java.math
class: MutableBigInteger [javadoc | source]
java.lang.Object
   java.math.MutableBigInteger

Direct Known Subclasses:
    SignedMutableBigInteger

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 reallocated 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.
Field Summary
 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. 
 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. 
 int offset    The offset into the value array where the magnitude of this MutableBigInteger begins. 
Constructor:
 MutableBigInteger() 
 MutableBigInteger(int val) 
 MutableBigInteger(int[] val) 
 MutableBigInteger(BigInteger b) 
    Construct a new MutableBigInteger with a magnitude equal to the specified BigInteger.
 MutableBigInteger(MutableBigInteger val) 
    Construct a new MutableBigInteger with a magnitude equal to the specified MutableBigInteger.
 MutableBigInteger(int[] val,
    int len) 
Method from java.math.MutableBigInteger Summary:
add,   binaryGcd,   clear,   compare,   copyValue,   copyValue,   divide,   divideOneWord,   euclidModInverse,   fixup,   hybridGCD,   inverseMod32,   isEven,   isNormal,   isOdd,   isOne,   isZero,   leftShift,   modInverseBP2,   modInverseMP2,   mul,   multiply,   mutableModInverse,   normalize,   reset,   rightShift,   setInt,   setValue,   subtract,   toIntArray,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.math.MutableBigInteger Detail:
  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.
 static int binaryGcd(int a,
    int b) 
    Calculate GCD of a and b interpreted as unsigned integers.
  void clear() 
    Clear out a MutableBigInteger for reuse.
 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 {@code b}.
  void copyValue(MutableBigInteger val) 
    Sets this MutableBigInteger's value array to a copy of the specified array. The intLen is set to the length of the new array.
  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.
  void divide(MutableBigInteger b,
    MutableBigInteger quotient,
    MutableBigInteger rem) 
    Calculates the quotient and remainder of this div b and places them in the MutableBigInteger objects provided. Uses Algorithm D in Knuth 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 contents of a and b are not changed.
  void 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. The value of this MutableBigInteger is the dividend at invocation but is replaced by the remainder. NOTE: The value of this MutableBigInteger is modified by this method.
 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.
 static MutableBigInteger fixup(MutableBigInteger c,
    MutableBigInteger p,
    int k) 
 MutableBigInteger hybridGCD(MutableBigInteger b) 
    Calculate GCD of this and b. This and b are changed by the computation.
 static int inverseMod32(int val) 
 boolean isEven() 
    Returns true iff this MutableBigInteger is even.
 boolean isNormal() 
    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 <= value.length.
 boolean isOdd() 
    Returns true iff this MutableBigInteger is odd.
 boolean isOne() 
    Returns true iff this MutableBigInteger has a value of one.
 boolean isZero() 
    Returns true iff this MutableBigInteger has a value of zero.
  void leftShift(int n) 
    Left shift this MutableBigInteger n bits.
 static MutableBigInteger modInverseBP2(MutableBigInteger mod,
    int k) 
 MutableBigInteger modInverseMP2(int k) 
  void mul(int y,
    MutableBigInteger z) 
    Multiply the contents of this MutableBigInteger by the word y. The result is placed into z.
  void multiply(MutableBigInteger y,
    MutableBigInteger z) 
    Multiply the contents of two MutableBigInteger objects. The result is placed into MutableBigInteger z. The contents of y are not changed.
 MutableBigInteger mutableModInverse(MutableBigInteger p) 
    Returns the modInverse of this mod p. This and p are not affected by the operation.
 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.
  void reset() 
    Set a MutableBigInteger to zero, removing its offset.
  void rightShift(int n) 
    Right shift this MutableBigInteger n bits. The MutableBigInteger is left in normal form.
  void setInt(int index,
    int val) 
    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.
  void setValue(int[] val,
    int length) 
    Sets this MutableBigInteger's value array to the specified array. The intLen is set to the specified length.
 int subtract(MutableBigInteger b) 
    Subtracts the smaller of this and b from the larger and places the result into this MutableBigInteger.
 int[] toIntArray() 
    Convert this MutableBigInteger into an int array with no leading zeros, of a length that is equal to this MutableBigInteger's intLen.
 public String toString() 
    Returns a String representation of this MutableBigInteger in radix 10.