APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.math

pack-priv final Class FDBigInteger

extends Object
Class Inheritance
Annotations
@AOTSafeClassInitializer
Imports
jdk.internal.misc.CDS, jdk.internal.vm.annotation.AOTSafeClassInitializer, .Stable, java.util.Arrays

A simple big integer class specifically for floating point base conversion.

Field Summary

Modifier and TypeField and Description
private static Object[]
private int[]
private boolean
private static final FDBigInteger[]
pack-priv static final long[]
private static final long
private static final int
private int
private int
private static final FDBigInteger[]
pack-priv static final int[]

Constructor Summary

AccessConstructor and Description
private
FDBigInteger(int[]
An array containing all non-zero ints of the value.
data
,
int
An offset indicating the number of zero ints to pad below the least significant element of data.
offset
)

Constructs an FDBigInteger from data and padding.

public
FDBigInteger(long
The starting value.
lValue
,
byte[]
The decimal digits.
digits
,
int
The initial index into digits.
i
,
int
The final index into digits.
nDigits
)

Constructs an FDBigInteger from a starting value and some decimal digits.

public
FDBigInteger(long v)

Method Summary

Modifier and TypeMethod and Description
private FDBigInteger

Returns:

The sum of the FDBigIntegers.
add
(FDBigInteger
The FDBigInteger to add.
other
)

Adds another FDBigInteger to this FDBigInteger.

public int

Returns:

-1, 0, or 1 according to the result of the comparison.
addAndCmp
(FDBigInteger
The first addend of the sum to compare.
x
,
FDBigInteger
The second addend of the sum to compare.
y
)

Compares this FDBigInteger with x + y.

private static int

Returns:

Zero if all elements in range are zero, 1 otherwise.
checkZeroTail
(int[]
The array to be examined.
a
,
int
The index strictly below which elements are to be examined.
from
)

Determines whether all elements of an array are zero for all indices less than a given index.

public int

Returns:

A negative value, zero, or a positive value according to the result of the comparison.
cmp
(FDBigInteger
The FDBigInteger to compare.
other
)

Compares the parameter with this FDBigInteger.

public int

Returns:

The normalization bias.
getNormalizationBias
()

Retrieves the normalization bias of the FDBigInteger.

public boolean

Returns:

this is zero.
isZero
()

Returns whether this FDBigInteger is zero.

private static void
leftShift(int[]
The source array.
src
,
int
The initial index of the source array.
idx
,
int[]
The destination array.
result
,
int
The left shift.
bitcount
,
int
The prior source value.
prev
)

Left shifts the contents of one int array into another.

public FDBigInteger

Returns:

The shifted FDBigInteger.
leftShift
(int
The number of bits to shift left.
shift
)

Shifts this FDBigInteger to the left.

public FDBigInteger

Returns:

this
makeImmutable
()

Makes this FDBigInteger immutable.

private static void
mult(int[]
The first array factor.
s1
,
int
The number of elements of s1 to use.
s1Len
,
int[]
The second array factor.
s2
,
int
The number of elements of s2 to use.
s2Len
,
int[]
The product array.
dst
)

Multiplies two big integers represented as int arrays.

public FDBigInteger

Returns:

This FDBigInteger multiplied by an integer.
mult
(int
The factor by which to multiply this FDBigInteger.
v
)

Multiplies this FDBigInteger by an integer.

private FDBigInteger

Returns:

The product of this and the parameter FDBigIntegers.
mult
(FDBigInteger
The FDBigInteger factor by which to multiply.
other
)

Multiplies this FDBigInteger by another FDBigInteger.

private static void
mult(int[]
The array representation of the big integer.
src
,
int
The number of elements of src to use.
srcLen
,
int
The constant factor by which to multiply.
value
,
int[]
The product array.
dst
)

Multiplies by a constant value a big integer represented as an array.

private static void
mult(int[]
The array representation of the big integer.
src
,
int
The number of elements of src to use.
srcLen
,
int
The lower 32 bits of the long factor.
v0
,
int
The upper 32 bits of the long factor.
v1
,
int[]
The product array.
dst
)

Multiplies by a constant value a big integer represented as an array.

private void
multAdd(int
The factor by which to multiply this FDBigInteger.
iv
,
int
The value to add to the product of this FDBigInteger and iv.
addend
)

Multiplies a FDBigInteger by an int and adds another int.

private static int

Returns:

The final carry of the multiplication.
multAndCarryBy10
(int[]
The array representation of the big integer.
src
,
int
The number of elements of src to use.
srcLen
,
int[]
The product array.
dst
)

Multiplies by 10 a big integer represented as an array.

public FDBigInteger

Returns:

The FDBigInteger multiplied by 10.
multBy10
()

Multiplies this FDBigInteger by 10.

public FDBigInteger

Returns:

The multiplication result.
multByPow52
(int
The exponent of the power-of-five factor.
e5
,
int
The exponent of the power-of-two factor.
e2
)

Multiplies this FDBigInteger by 5e5 * 2e2.

private long

Returns:

this - q*S.
multSub
(long
The integer parameter.
q
,
FDBigInteger
The FDBigInteger parameter.
S
)

Multiplies the parameters and subtracts them from this FDBigInteger.

private static FDBigInteger

Returns:

5e.
pow5
(int
The exponent of 5.
e
)

Computes 5e.

public int

Returns:

q = (int)(this / S).
quoRemIteration
(FDBigInteger
The divisor of this FDBigInteger.
S
)

Computes

q = (int)( this / S )
this = 10 * ( this mod S )
Return q.
private int

Returns:

Number of ints required to represent this FDBigInteger.
size
()

Returns the number of ints this FDBigInteger represents.

public byte[]

Returns:

The byte[] representation.
toByteArray
()

Converts this FDBigInteger to a byte[] suitable for use with java.math.BigInteger#BigInteger(byte[]).

public String

Returns:

The hexadecimal string representation.
toString
()

Overrides java.lang.Object.toString.

Converts this FDBigInteger to a hexadecimal string.

private void
trimLeadingZeros()

Removes all leading zeros from this FDBigInteger adjusting the offset and number of non-zero leading words accordingly.

public static FDBigInteger

Returns:

value * 5e5 * 2e2
valueOfMulPow52
(long
The constant factor.
value
,
int
The exponent of the power-of-five factor.
e5
,
int
The exponent of the power-of-two factor.
e2
)

Returns an FDBigInteger with the numerical value: value * 5e5 * 2e2.

private static FDBigInteger

Returns:

2e
valueOfPow2
(int
The exponent of 2.
e
)

Returns an FDBigInteger with the numerical value 2e.

public static FDBigInteger

Returns:

5e5 * 2e2
valueOfPow52
(int
The exponent of the power-of-five factor.
e5
,
int
The exponent of the power-of-two factor.
e2
)

Returns an FDBigInteger with the numerical value 5e5 * 2e2.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

archivedCachesback to summary
private static Object[] archivedCaches
databack to summary
private int[] data
isImmutableback to summary
private boolean isImmutable
LARGE_POW_5_CACHEback to summary
private static final FDBigInteger[] LARGE_POW_5_CACHE
Annotations
@Stable
LONG_5_POWback to summary
pack-priv static final long[] LONG_5_POW
Annotations
@Stable
LONG_MASKback to summary
private static final long LONG_MASK
MAX_FIVE_POWback to summary
private static final int MAX_FIVE_POW
nWordsback to summary
private int nWords
offsetback to summary
private int offset
POW_5_CACHEback to summary
private static final FDBigInteger[] POW_5_CACHE
Annotations
@Stable
SMALL_5_POWback to summary
pack-priv static final int[] SMALL_5_POW
Annotations
@Stable

Constructor Detail

FDBigIntegerback to summary
private FDBigInteger(int[] data, int offset)

Constructs an FDBigInteger from data and padding. The data parameter has the least significant int at the zeroth index. The offset parameter gives the number of zero ints to be inferred below the least significant element of data.

Parameters
data:int[]

An array containing all non-zero ints of the value.

offset:int

An offset indicating the number of zero ints to pad below the least significant element of data.

FDBigIntegerback to summary
public FDBigInteger(long lValue, byte[] digits, int i, int nDigits)

Constructs an FDBigInteger from a starting value and some decimal digits.

Parameters
lValue:long

The starting value.

digits:byte[]

The decimal digits.

i:int

The initial index into digits.

nDigits:int

The final index into digits.

FDBigIntegerback to summary
public FDBigInteger(long v)

Method Detail

addback to summary
private FDBigInteger add(FDBigInteger other)

Adds another FDBigInteger to this FDBigInteger.

Parameters
other:FDBigInteger

The FDBigInteger to add.

Returns:FDBigInteger

The sum of the FDBigIntegers.

addAndCmpback to summary
public int addAndCmp(FDBigInteger x, FDBigInteger y)

Compares this FDBigInteger with x + y. Returns a value according to the comparison as:

-1: this <  x + y
 0: this == x + y
 1: this >  x + y
Parameters
x:FDBigInteger

The first addend of the sum to compare.

y:FDBigInteger

The second addend of the sum to compare.

Returns:int

-1, 0, or 1 according to the result of the comparison.

checkZeroTailback to summary
private static int checkZeroTail(int[] a, int from)

Determines whether all elements of an array are zero for all indices less than a given index.

Parameters
a:int[]

The array to be examined.

from:int

The index strictly below which elements are to be examined.

Returns:int

Zero if all elements in range are zero, 1 otherwise.

cmpback to summary
public int cmp(FDBigInteger other)

Compares the parameter with this FDBigInteger. Returns an integer accordingly as:

> 0: this > other
  0: this == other
< 0: this < other
Parameters
other:FDBigInteger

The FDBigInteger to compare.

Returns:int

A negative value, zero, or a positive value according to the result of the comparison.

getNormalizationBiasback to summary
public int getNormalizationBias()

Retrieves the normalization bias of the FDBigInteger. 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.

Returns:int

The normalization bias.

isZeroback to summary
public boolean isZero()

Returns whether this FDBigInteger is zero.

Returns:boolean

this is zero.

leftShiftback to summary
private static void leftShift(int[] src, int idx, int[] result, int bitcount, int prev)

Left shifts the contents of one int array into another.

Parameters
src:int[]

The source array.

idx:int

The initial index of the source array.

result:int[]

The destination array.

bitcount:int

The left shift.

prev:int

The prior source value.

leftShiftback to summary
public FDBigInteger leftShift(int shift)

Shifts this 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.

Parameters
shift:int

The number of bits to shift left.

Returns:FDBigInteger

The shifted FDBigInteger.

makeImmutableback to summary
public FDBigInteger makeImmutable()

Makes this FDBigInteger immutable.

Returns:FDBigInteger

this

multback to summary
private static void mult(int[] s1, int s1Len, int[] s2, int s2Len, int[] dst)

Multiplies two big integers represented as int arrays.

Parameters
s1:int[]

The first array factor.

s1Len:int

The number of elements of s1 to use.

s2:int[]

The second array factor.

s2Len:int

The number of elements of s2 to use.

dst:int[]

The product array.

multback to summary
public FDBigInteger mult(int v)

Multiplies this FDBigInteger by an integer.

Parameters
v:int

The factor by which to multiply this FDBigInteger.

Returns:FDBigInteger

This FDBigInteger multiplied by an integer.

multback to summary
private FDBigInteger mult(FDBigInteger other)

Multiplies this FDBigInteger by another FDBigInteger.

Parameters
other:FDBigInteger

The FDBigInteger factor by which to multiply.

Returns:FDBigInteger

The product of this and the parameter FDBigIntegers.

multback to summary
private static void mult(int[] src, int srcLen, int value, int[] dst)

Multiplies by a constant value a big integer represented as an array. The constant factor is an int.

Parameters
src:int[]

The array representation of the big integer.

srcLen:int

The number of elements of src to use.

value:int

The constant factor by which to multiply.

dst:int[]

The product array.

multback to summary
private static void mult(int[] src, int srcLen, int v0, int v1, int[] dst)

Multiplies by a constant value a big integer represented as an array. The constant factor is a long represent as two ints.

Parameters
src:int[]

The array representation of the big integer.

srcLen:int

The number of elements of src to use.

v0:int

The lower 32 bits of the long factor.

v1:int

The upper 32 bits of the long factor.

dst:int[]

The product array.

multAddback to summary
private void multAdd(int iv, int addend)

Multiplies a FDBigInteger by an int and adds another int. The result is computed in place. This method is intended only to be invoked from FDBigInteger(long, char[], int, int).

Parameters
iv:int

The factor by which to multiply this FDBigInteger.

addend:int

The value to add to the product of this FDBigInteger and iv.

multAndCarryBy10back to summary
private static int multAndCarryBy10(int[] src, int srcLen, int[] dst)

Multiplies by 10 a big integer represented as an array. The final carry is returned.

Parameters
src:int[]

The array representation of the big integer.

srcLen:int

The number of elements of src to use.

dst:int[]

The product array.

Returns:int

The final carry of the multiplication.

multBy10back to summary
public FDBigInteger multBy10()

Multiplies this FDBigInteger by 10. The operation will be performed in place unless the FDBigInteger is immutable in which case a new FDBigInteger will be returned.

Returns:FDBigInteger

The FDBigInteger multiplied by 10.

multByPow52back to summary
public FDBigInteger multByPow52(int e5, int e2)

Multiplies this FDBigInteger by 5e5 * 2e2. The operation will be performed in place if possible, otherwise a new FDBigInteger will be returned.

Parameters
e5:int

The exponent of the power-of-five factor.

e2:int

The exponent of the power-of-two factor.

Returns:FDBigInteger

The multiplication result.

multSubback to summary
private long multSub(long q, FDBigInteger S)

Multiplies the parameters and subtracts them from this FDBigInteger.

Parameters
q:long

The integer parameter.

S:FDBigInteger

The FDBigInteger parameter.

Returns:long

this - q*S.

pow5back to summary
private static FDBigInteger pow5(int e)

Computes 5e.

Parameters
e:int

The exponent of 5.

Returns:FDBigInteger

5e.

Exceptions
IllegalArgumentException:
if e > 2 - DoubleToDecimal.Q_MIN = 1076
quoRemIterationback to summary
public int quoRemIteration(FDBigInteger S) throws IllegalArgumentException

Computes

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.
Parameters
S:FDBigInteger

The divisor of this FDBigInteger.

Returns:int

q = (int)(this / S).

sizeback to summary
private int size()

Returns the number of ints this FDBigInteger represents.

Returns:int

Number of ints required to represent this FDBigInteger.

toByteArrayback to summary
public byte[] toByteArray()

Converts this FDBigInteger to a byte[] suitable for use with java.math.BigInteger#BigInteger(byte[]).

Returns:byte[]

The byte[] representation.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Converts this FDBigInteger to a hexadecimal string.

Returns:String

The hexadecimal string representation.

Annotations
@Override
trimLeadingZerosback to summary
private void trimLeadingZeros()

Removes all leading zeros from this FDBigInteger adjusting the offset and number of non-zero leading words accordingly.

valueOfMulPow52back to summary
public static FDBigInteger valueOfMulPow52(long value, int e5, int e2)

Returns an FDBigInteger with the numerical value: value * 5e5 * 2e2.

Parameters
value:long

The constant factor.

e5:int

The exponent of the power-of-five factor.

e2:int

The exponent of the power-of-two factor.

Returns:FDBigInteger

value * 5e5 * 2e2

valueOfPow2back to summary
private static FDBigInteger valueOfPow2(int e)

Returns an FDBigInteger with the numerical value 2e.

Parameters
e:int

The exponent of 2.

Returns:FDBigInteger

2e

valueOfPow52back to summary
public static FDBigInteger valueOfPow52(int e5, int e2)

Returns an FDBigInteger with the numerical value 5e5 * 2e2.

Parameters
e5:int

The exponent of the power-of-five factor.

e2:int

The exponent of the power-of-two factor.

Returns:FDBigInteger

5e5 * 2e2