public class MathUtils extends Object
Various math utility methods, also backports from later JDK versions.
Constructor and Description |
---|
MathUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
floorDiv(long x,
long y)
Backport of floorDiv from the JDK since we need to support 1.6.
|
static long |
floorMod(long x,
long y)
Backport of floorMod from the JDK since we need to support 1.6.
|
public static long floorMod(long x, long y)
Backport of floorMod from the JDK since we need to support 1.6.
Returns the largest (closest to positive infinity) long
value that is less than or equal to the algebraic quotient. There is one special case, if the dividend is the Long.MIN_VALUE and the divisor is -1
, then integer overflow occurs and the result is equal to the Long.MIN_VALUE
.
Normal integer division operates under the round to zero rounding mode (truncation). This operation instead acts under the round toward negative infinity (floor) rounding mode. The floor rounding mode gives different results than truncation when the exact result is negative.
x
- the dividendy
- the divisorlong
value that is less than or equal to the algebraic quotient.ArithmeticException
- if the divisor y
is zeropublic static long floorDiv(long x, long y)
Backport of floorDiv from the JDK since we need to support 1.6.
Returns the largest (closest to positive infinity) long
value that is less than or equal to the algebraic quotient. There is one special case, if the dividend is the Long.MIN_VALUE and the divisor is -1
, then integer overflow occurs and the result is equal to the Long.MIN_VALUE
.
Normal integer division operates under the round to zero rounding mode (truncation). This operation instead acts under the round toward negative infinity (floor) rounding mode. The floor rounding mode gives different results than truncation when the exact result is negative.
x
- the dividendy
- the divisorlong
value that is less than or equal to the algebraic quotient.ArithmeticException
- if the divisor y
is zerofloorMod(long, long)
Copyright © 2018 Couchbase, Inc.. All rights reserved.