Class UInt192
java.lang.Object
org.apache.commons.statistics.descriptive.UInt192
A mutable 192-bit unsigned integer.
This is a specialised class to implement an accumulator of squared long values.
- Since:
- 1.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidAdds the value.(package private) voidaddSquare(long x) Adds the squared valuex * x.(package private) static UInt192create()Create an instance.(package private) longhi64()Return the higher 64-bits as alongvalue.(package private) longlo64()Return the lower 64-bits as alongvalue.(package private) longmid64()Return the middle 64-bits as alongvalue.(package private) UInt192Subtracts the value.(package private) BigIntegerConvert to a BigInteger.(package private) doubletoDouble()Convert to a double.(package private) intConvert to anint; throwing an exception if the value overflows anint.(package private) longConvert to along; throwing an exception if the value overflows along.(package private) UInt192unsignedMultiply(int x) Multiply by the unsigned value.
-
Field Details
-
MASK32
private static final long MASK32Mask for the lower 32-bits of a long.- See Also:
-
f
private int fbits 32-1 (low 32-bits). -
e
private int ebits 64-33. -
d
private int dbits 96-65. -
c
private int cbits 128-97. -
ab
private long abbits 192-129 (high 64-bits).
-
-
Constructor Details
-
UInt192
private UInt192()Create an instance. -
UInt192
UInt192(long hi, long mid, long lo) Create an instance using a direct binary representation. This is package-private for testing.- Parameters:
hi- High 64-bits.mid- Middle 64-bits.lo- Low 64-bits.
-
UInt192
private UInt192(long ab, int c, int d, int e, int f) Create an instance using a direct binary representation.- Parameters:
ab- bits 192-129 (high 64-bits).c- bits 128-97.d- bits 96-65.e- bits 64-33.f- bits 32-1.
-
-
Method Details
-
create
-
addSquare
void addSquare(long x) Adds the squared valuex * x.- Parameters:
x- Value.
-
add
-
unsignedMultiply
Multiply by the unsigned value. Any overflow bits are lost.- Parameters:
x- Value.- Returns:
- the product
-
subtract
-
toBigInteger
-
toDouble
double toDouble()Convert to a double.- Returns:
- the value
-
toIntExact
int toIntExact()Convert to anint; throwing an exception if the value overflows anint.- Returns:
- the value
- Throws:
ArithmeticException- if the value overflows anint.- See Also:
-
toLongExact
long toLongExact()Convert to along; throwing an exception if the value overflows along.- Returns:
- the value
- Throws:
ArithmeticException- if the value overflows along.
-
lo64
long lo64()Return the lower 64-bits as alongvalue.- Returns:
- the low 64-bits
-
mid64
long mid64()Return the middle 64-bits as alongvalue.- Returns:
- bits 128-65
-
hi64
long hi64()Return the higher 64-bits as alongvalue.- Returns:
- bits 192-129
-