Top Inners Fields Constructors Methods
ch.randelshofer.fastdoubleparser

pack-priv Class FastIntegerMath

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.util.Iterator, .Map, .NavigableMap, .TreeMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
public static final BigInteger
pack-priv static final BigInteger
private static final BigInteger[]
pack-priv static final BigInteger

Constructor Summary

AccessConstructor and Description
private
FastIntegerMath()

Don't let anyone instantiate this class.

Method Summary

Modifier and TypeMethod and Description
pack-priv static BigInteger

Returns:

the computed power of ten
computePowerOfTen
(NavigableMap<Integer, BigInteger>
A map with pre-computed powers of ten
powersOfTen
,
int
the power
n
)

Computes the n-th power of ten.

pack-priv static BigInteger
computeTenRaisedByNFloor16Recursive(NavigableMap<Integer, BigInteger> powersOfTen, int n)

Computes 10n&~15.

pack-priv static NavigableMap<Integer, BigInteger>
public static long
estimateNumBits(long numDecimalDigits)

pack-priv static NavigableMap<Integer, BigInteger>

Returns:

the filled map
fillPowersOf10Floor16
(int
the start index of the character sequence that contains the digits
from
,
int
the end index of the character sequence that contains the digits
to
)

Fills a map with powers of 10 floor 16.

pack-priv static void
pack-priv static FastIntegerMath.UInt128

Returns:

uint128 product of x and y
fullMultiplication
(long
uint64 factor x
x
,
long
uint64 factor y
y
)

Computes uint128 product = (uint64)x * (uint64)y.

pack-priv static int
splitFloor16(int from, int to)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FIVEback to summary
public static final BigInteger FIVE
FIVE_POW_16back to summary
pack-priv static final BigInteger FIVE_POW_16
SMALL_POWERS_OF_TENback to summary
private static final BigInteger[] SMALL_POWERS_OF_TEN
TEN_POW_16back to summary
pack-priv static final BigInteger TEN_POW_16

Constructor Detail

FastIntegerMathback to summary
private FastIntegerMath()

Don't let anyone instantiate this class.

Method Detail

computePowerOfTenback to summary
pack-priv static BigInteger computePowerOfTen(NavigableMap<Integer, BigInteger> powersOfTen, int n)

Computes the n-th power of ten.

Parameters
powersOfTen:NavigableMap<Integer, BigInteger>

A map with pre-computed powers of ten

n:int

the power

Returns:BigInteger

the computed power of ten

computeTenRaisedByNFloor16Recursiveback to summary
pack-priv static BigInteger computeTenRaisedByNFloor16Recursive(NavigableMap<Integer, BigInteger> powersOfTen, int n)

Computes 10n&~15.

createPowersOfTenFloor16Mapback to summary
pack-priv static NavigableMap<Integer, BigInteger> createPowersOfTenFloor16Map()
estimateNumBitsback to summary
public static long estimateNumBits(long numDecimalDigits)
fillPowersOf10Floor16back to summary
pack-priv static NavigableMap<Integer, BigInteger> fillPowersOf10Floor16(int from, int to)

Fills a map with powers of 10 floor 16.

Parameters
from:int

the start index of the character sequence that contains the digits

to:int

the end index of the character sequence that contains the digits

Returns:NavigableMap<Integer, BigInteger>

the filled map

fillPowersOfNFloor16Recursiveback to summary
pack-priv static void fillPowersOfNFloor16Recursive(NavigableMap<Integer, BigInteger> powersOfTen, int from, int to)
fullMultiplicationback to summary
pack-priv static FastIntegerMath.UInt128 fullMultiplication(long x, long y)

Computes uint128 product = (uint64)x * (uint64)y.

References:

Getting the high part of 64 bit integer multiplication
stackoverflow
Parameters
x:long

uint64 factor x

y:long

uint64 factor y

Returns:FastIntegerMath.UInt128

uint128 product of x and y

splitFloor16back to summary
pack-priv static int splitFloor16(int from, int to)
ch.randelshofer.fastdoubleparser back to summary

pack-priv Class FastIntegerMath.UInt128

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final long
pack-priv final long

Constructor Summary

AccessConstructor and Description
private
UInt128(long high, long low)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

highback to summary
pack-priv final long high
lowback to summary
pack-priv final long low

Constructor Detail

UInt128back to summary
private UInt128(long high, long low)