Class UInt96
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.UInt96
-
final class UInt96 extends java.lang.Object
A mutable 96-bit unsigned integer.This is a specialised class to implement an accumulator of
long
values generated by squaringint
values 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) void
add(UInt96 x)
Adds the value.(package private) void
addPositive(long x)
Adds the value.(package private) static UInt96
create()
Create an instance.(package private) long
hi64()
Return the higher 64-bits as along
value.(package private) int
lo32()
Return the lower 32-bits as anint
value.(package private) static UInt96
of(long x)
Create an instance of thelong
value.(package private) java.math.BigInteger
toBigInteger()
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 thelong
value. 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 anint
value. 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 anint
value.- Returns:
- bits 32-1
-
hi64
long hi64()
Return the higher 64-bits as along
value.- Returns:
- bits 96-33
-
-