com.couchbase.client.core.utils

## Class MathUtils

• ```public class MathUtils
extends Object```

Various math utility methods, also backports from later JDK versions.

Since:
1.3.4
Author:
Michael Nitschinger
• ### Constructor Summary

Constructors
Constructor and Description
`MathUtils()`
• ### Method Summary

All Methods
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.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### MathUtils

`public MathUtils()`
• ### Method Detail

• #### floorMod

```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.

Parameters:
`x` - the dividend
`y` - the divisor
Returns:
the largest (closest to positive infinity) `long` value that is less than or equal to the algebraic quotient.
Throws:
`ArithmeticException` - if the divisor `y` is zero
• #### floorDiv

```public 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.

Parameters:
`x` - the dividend
`y` - the divisor
Returns:
the largest (closest to positive infinity) `long` value that is less than or equal to the algebraic quotient.
Throws:
`ArithmeticException` - if the divisor `y` is zero
`floorMod(long, long)`