Package convex.core.util
Class Huge
java.lang.Object
convex.core.util.Huge
A 128-bit integer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionadd(long b)
Creates a Huge by adding a long value to this Hugestatic Huge
add(long a, long b)
Creates a Huge by adding two signed longsCreates a Huge by adding another Hugestatic Huge
create(long a)
Creates a new Huge by sign extending a long to 128 bitsboolean
Tests if this Huge is equal to another Hugeboolean
static Long
fusedMultiplyDivide(long a, long b, long c)
Performs a fused multiply and divide (a * b) / c.static Huge
multiply(long a, long b)
Creates a new Huge by multiplying two signed longsstatic Huge
Creates a new Huge by multiplying a Huge with a signed longnegate()
Negates this Huge valuetoString()
-
Field Details
-
ZERO
-
ONE
-
hi
public final long hi -
lo
public final long lo
-
-
Method Details
-
create
Creates a new Huge by sign extending a long to 128 bits- Parameters:
a
- Any signed 64-bit long value- Returns:
- New Huge instance
-
multiply
Creates a new Huge by multiplying two signed longs- Parameters:
a
- Any signed 64-bit long valueb
- Any signed 64-bit long value- Returns:
- Huge product of arguments
-
multiply
Creates a new Huge by multiplying a Huge with a signed long- Parameters:
a
- Any signed 128-bit Huge valueb
- Any signed 64-bit long value- Returns:
- Huge product of arguments
-
add
Creates a Huge by adding two signed longs- Parameters:
a
- Any signed 64-bit long valueb
- Any signed 64-bit long value- Returns:
- Huge sum of arguments
-
add
Creates a Huge by adding a long value to this Huge- Parameters:
b
- Any signed 64-bit long value- Returns:
- Huge sum of arguments
-
fusedMultiplyDivide
Performs a fused multiply and divide (a * b) / c. Handles cases where (a*b) would overflow a single 64-bit long.- Parameters:
a
- First multiplicandb
- Second multiplicandc
- Divisor- Returns:
- Result of operation, of null if result overflows a Long
-
add
Creates a Huge by adding another Huge- Parameters:
b
- Any Huge value- Returns:
- Huge sum of arguments
-
equals
-
equals
Tests if this Huge is equal to another Huge- Parameters:
a
- Another Huge instance (must not be null)- Returns:
- true is the Huge values are equal, false otherwise
-
toString
-
sub
-
negate
Negates this Huge value- Returns:
- Huge negation of this value
-
mul
-