Class UInt96
java.lang.Object
org.apache.commons.statistics.descriptive.UInt96
A mutable 96-bit unsigned integer.
This is a specialised class to implement an accumulator of long
values
generated by squaring int
values from an array (max observations=2^31).
- Since:
- 1.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
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) BigInteger
Convert to a BigInteger.
-
Field Details
-
MASK32
private static final long MASK32Mask for the lower 32-bits of a long.- See Also:
-
c
private int cbits 32-1 (low 32-bits). -
ab
private long abbits 96-33.
-
-
Constructor Details
-
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 Details
-
create
Create an instance. The initial value is zero.- Returns:
- the instance
-
of
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
Adds the value.- Parameters:
x
- Value.
-
toBigInteger
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
-