Package ch.randelshofer.fastdoubleparser
Class FastIntegerMath
- java.lang.Object
-
- ch.randelshofer.fastdoubleparser.FastIntegerMath
-
final class FastIntegerMath extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigIntegerFIVE(package private) static java.math.BigIntegerFIVE_POW_16private static java.math.BigInteger[]SMALL_POWERS_OF_TEN(package private) static java.math.BigIntegerTEN_POW_16
-
Constructor Summary
Constructors Modifier Constructor Description privateFastIntegerMath()Don't let anyone instantiate this class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.math.BigIntegercomputePowerOfTen(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int n)Computes the n-th power of ten.(package private) static java.math.BigIntegercomputeTenRaisedByNFloor16Recursive(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int n)Computes 10n&~15.(package private) static java.util.NavigableMap<java.lang.Integer,java.math.BigInteger>createPowersOfTenFloor16Map()static longestimateNumBits(long numDecimalDigits)(package private) static java.util.NavigableMap<java.lang.Integer,java.math.BigInteger>fillPowersOf10Floor16(int from, int to)Fills a map with powers of 10 floor 16.(package private) static voidfillPowersOfNFloor16Recursive(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int from, int to)(package private) static intsplitFloor16(int from, int to)Finds middle of range with upper range half rounded up to multiple of 16.(package private) static longunsignedMultiplyHigh(long x, long y)Computesuint128 product = (uint64)x * (uint64)y.
-
-
-
Method Detail
-
computePowerOfTen
static java.math.BigInteger computePowerOfTen(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int n)Computes the n-th power of ten.- Parameters:
powersOfTen- A map with pre-computed powers of tenn- the power- Returns:
- the computed power of ten
-
computeTenRaisedByNFloor16Recursive
static java.math.BigInteger computeTenRaisedByNFloor16Recursive(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int n)Computes 10n&~15.
-
createPowersOfTenFloor16Map
static java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> createPowersOfTenFloor16Map()
-
estimateNumBits
public static long estimateNumBits(long numDecimalDigits)
-
fillPowersOf10Floor16
static java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> fillPowersOf10Floor16(int from, int to)Fills a map with powers of 10 floor 16.- Parameters:
from- the start index of the character sequence that contains the digitsto- the end index of the character sequence that contains the digits- Returns:
- the filled map
-
fillPowersOfNFloor16Recursive
static void fillPowersOfNFloor16Recursive(java.util.NavigableMap<java.lang.Integer,java.math.BigInteger> powersOfTen, int from, int to)
-
unsignedMultiplyHigh
static long unsignedMultiplyHigh(long x, long y)Computesuint128 product = (uint64)x * (uint64)y.References:
- Getting the high part of 64 bit integer multiplication
- stackoverflow
- Parameters:
x- uint64 factor xy- uint64 factor y- Returns:
- uint128 product of x and y
-
splitFloor16
static int splitFloor16(int from, int to)Finds middle of range with upper range half rounded up to multiple of 16.- Parameters:
from- start of range (inclusive)to- end of range (exclusive)- Returns:
- middle of range with upper range half rounded up to multiple of 16
-
-