java.math
class: SignedMutableBigInteger [javadoc |
source]
java.lang.Object
java.math.MutableBigInteger
java.math.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 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.
Also see:
- BigInteger
- author:
Michael - McCloskey
- since:
1.3 -
| Field Summary |
|---|
| int | sign | The sign of this MutableBigInteger. |
| Methods from java.math.MutableBigInteger: |
|---|
|
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.SignedMutableBigInteger Detail: |
void signedAdd(SignedMutableBigInteger addend) {
if (sign == addend.sign)
add(addend);
else
sign = sign * subtract(addend);
}
Signed addition built upon unsigned add and subtract. |
void signedAdd(MutableBigInteger addend) {
if (sign == 1)
add(addend);
else
sign = sign * subtract(addend);
}
Signed addition built upon unsigned add and subtract. |
void signedSubtract(SignedMutableBigInteger addend) {
if (sign == addend.sign)
sign = sign * subtract(addend);
else
add(addend);
}
Signed subtraction built upon unsigned add and subtract. |
void signedSubtract(MutableBigInteger addend) {
if (sign == 1)
sign = sign * subtract(addend);
else
add(addend);
if (intLen == 0)
sign = 1;
}
Signed subtraction built upon unsigned add and subtract. |
public String toString() {
BigInteger b = new BigInteger(this, sign);
return
b.toString();
}
Print out the first intLen ints of this MutableBigInteger's value
array starting at offset. |