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) voidAdds 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) BigIntegerConvert 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
-
of
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
-
toBigInteger
-
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
-