Class UInt96
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.UInt96
-
final class UInt96 extends java.lang.ObjectA mutable 96-bit unsigned integer.This is a specialised class to implement an accumulator of
longvalues generated by squaringintvalues from an array (max observations=2^31).- Since:
- 1.1
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(UInt96 x)Adds the value.(package private) voidaddPositive(long x)Adds the value.(package private) static UInt96create()Create an instance.(package private) longhi64()Return the higher 64-bits as alongvalue.(package private) intlo32()Return the lower 32-bits as anintvalue.(package private) static UInt96of(long x)Create an instance of thelongvalue.(package private) java.math.BigIntegertoBigInteger()Convert to a BigInteger.
-
-
-
Field Detail
-
MASK32
private static final long MASK32
Mask for the lower 32-bits of a long.- See Also:
- Constant Field Values
-
c
private int c
bits 32-1 (low 32-bits).
-
ab
private long ab
bits 96-33.
-
-
Constructor Detail
-
UInt96
private UInt96()
Create an instance.
-
UInt96
private UInt96(long x)
Create an instance.- Parameters:
x- Value.
-
UInt96
UInt96(long hi, int lo)Create an instance using a direct binary representation. This is package-private for testing.- Parameters:
hi- High 64-bits.lo- Low 32-bits.
-
-
Method Detail
-
create
static UInt96 create()
Create an instance. The initial value is zero.- Returns:
- the instance
-
of
static UInt96 of(long x)
Create an instance of thelongvalue. The value is assumed to be an unsigned 64-bit integer.- Parameters:
x- Value (must be positive).- Returns:
- the instance
-
addPositive
void addPositive(long x)
Adds the value. It is assumed to be positive, for example the square of anintvalue. However no check is performed for a negative value.Note: This addition handles -9223372036854775808L as an unsigned value of 2^63.
- Parameters:
x- Value.
-
add
void add(UInt96 x)
Adds the value.- Parameters:
x- Value.
-
toBigInteger
java.math.BigInteger toBigInteger()
Convert to a BigInteger.- Returns:
- the value
-
lo32
int lo32()
Return the lower 32-bits as anintvalue.- Returns:
- bits 32-1
-
hi64
long hi64()
Return the higher 64-bits as alongvalue.- Returns:
- bits 96-33
-
-