public class FDBigInteger
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static FDBigInteger |
FIVE |
static FDBigInteger |
ONE |
static FDBigInteger |
ZERO |
Constructor and Description |
---|
FDBigInteger(long lValue,
char[] digits,
int kDigits,
int nDigits)
Constructs an
FDBigInteger from a starting value and some decimal digits. |
Modifier and Type | Method and Description |
---|---|
int |
addAndCmp(FDBigInteger x,
FDBigInteger y)
Compares this
FDBigInteger with x + y . |
int |
cmp(FDBigInteger other)
Compares the parameter with this
FDBigInteger . |
int |
cmpPow52(int p5,
int p2)
Compares this
FDBigInteger with 5p5 * 2p2 . |
int |
getNormalizationBias()
Retrieves the normalization bias of the
FDBigIntger . |
FDBigInteger |
leftInplaceSub(FDBigInteger subtrahend)
Subtracts the supplied
FDBigInteger subtrahend from this FDBigInteger . |
FDBigInteger |
leftShift(int shift)
Shifts this
FDBigInteger to the left. |
void |
makeImmutable()
Makes this
FDBigInteger immutable. |
FDBigInteger |
multBy10()
Multiplies this
FDBigInteger by 10. |
FDBigInteger |
multByPow52(int p5,
int p2)
Multiplies this
FDBigInteger by 5p5 * 2p2 . |
int |
quoRemIteration(FDBigInteger S)
Computes
|
FDBigInteger |
rightInplaceSub(FDBigInteger subtrahend)
Subtracts the supplied
FDBigInteger subtrahend from this FDBigInteger . |
BigInteger |
toBigInteger()
Converts this
FDBigInteger to a BigInteger . |
java.lang.String |
toHexString()
Converts this
FDBigInteger to a hexadecimal string. |
static FDBigInteger |
valueOfMulPow52(long value,
int p5,
int p2)
Returns an
FDBigInteger with the numerical value
value * 5p5 * 2p2 . |
static FDBigInteger |
valueOfPow52(int p5,
int p2)
Returns an
FDBigInteger with the numerical value 5p5 * 2p2 . |
public static final FDBigInteger ZERO
public static final FDBigInteger ONE
public static final FDBigInteger FIVE
public FDBigInteger(long lValue, char[] digits, int kDigits, int nDigits)
FDBigInteger
from a starting value and some decimal digits.lValue
- The starting value.digits
- The decimal digits.kDigits
- The initial index into digits
.nDigits
- The final index into digits
.public static FDBigInteger valueOfPow52(int p5, int p2)
FDBigInteger
with the numerical value 5p5 * 2p2
.p5
- The exponent of the power-of-five factor.p2
- The exponent of the power-of-two factor.5p5 * 2p2
public static FDBigInteger valueOfMulPow52(long value, int p5, int p2)
FDBigInteger
with the numerical value
value * 5p5 * 2p2
.value
- The constant factor.p5
- The exponent of the power-of-five factor.p2
- The exponent of the power-of-two factor.value * 5p5 * 2p2
public int getNormalizationBias()
FDBigIntger
. The normalization bias is a left shift such
that after it the highest word of the value will have the 4 highest bits equal to zero:
(highestWord & 0xf0000000) == 0
, but the next bit should be 1
(highestWord & 0x08000000) != 0
.public FDBigInteger leftShift(int shift)
FDBigInteger
to the left. The shift is performed in-place unless the
FDBigInteger
is immutable in which case a new instance of FDBigInteger
is returned.shift
- The number of bits to shift left.FDBigInteger
.public int quoRemIteration(FDBigInteger S) throws java.lang.IllegalArgumentException
q = (int)( this / S ) this = 10 * ( this mod S ) Return q.This is the iteration step of digit development for output. We assume that S has been normalized, as above, and that "this" has been left-shifted accordingly. Also assumed, of course, is that the result, q, can be expressed as an integer, 0 <= q < 10.
S
- The divisor of this FDBigInteger
.q = (int)(this / S)
.java.lang.IllegalArgumentException
public FDBigInteger multBy10()
FDBigInteger
by 10. The operation will be performed in place unless the
FDBigInteger
is immutable in which case a new FDBigInteger
will be returned.FDBigInteger
multiplied by 10.public FDBigInteger multByPow52(int p5, int p2)
FDBigInteger
by 5p5 * 2p2
. The operation will be
performed in place if possible, otherwise a new FDBigInteger
will be returned.p5
- The exponent of the power-of-five factor.p2
- The exponent of the power-of-two factor.public FDBigInteger leftInplaceSub(FDBigInteger subtrahend)
FDBigInteger
subtrahend from this FDBigInteger
. Assert that the
result is positive. If the subtrahend is immutable, store the result in this(minuend). If this(minuend) is
immutable a new FDBigInteger
is created.subtrahend
- The FDBigInteger
to be subtracted.FDBigInteger
less the subtrahend.public FDBigInteger rightInplaceSub(FDBigInteger subtrahend)
FDBigInteger
subtrahend from this FDBigInteger
. Assert that the
result is positive. If the this(minuend) is immutable, store the result in subtrahend. If subtrahend is immutable
a new FDBigInteger
is created.subtrahend
- The FDBigInteger
to be subtracted.FDBigInteger
less the subtrahend.public int cmp(FDBigInteger other)
FDBigInteger
. Returns an integer accordingly as:
>0: this > other 0: this == other <0: this < other
other
- The FDBigInteger
to compare.public int cmpPow52(int p5, int p2)
FDBigInteger
with 5p5 * 2p2
. Returns an integer
accordingly as:
>0: this > other 0: this == other <0: this < other
p5
- The exponent of the power-of-five factor.p2
- The exponent of the power-of-two factor.public int addAndCmp(FDBigInteger x, FDBigInteger y)
FDBigInteger
with x + y
. Returns a value according to the comparison as:
-1: this < x + y 0: this == x + y 1: this > x + y
x
- The first addend of the sum to compare.y
- The second addend of the sum to compare.public void makeImmutable()
FDBigInteger
immutable.public java.lang.String toHexString()
FDBigInteger
to a hexadecimal string.public BigInteger toBigInteger()
FDBigInteger
to a BigInteger
.BigInteger
representation.