Math
Math on Integral Types
- IntMath
- LongMath
- BigIntegerMath
Checked Arithmetic
IntMath |
LongMath |
|---|---|
IntMath.checkedAdd |
LongMath.checkedAdd |
IntMath.checkedSubtract |
LongMath.checkedSubtract |
IntMath.checkedMultiply |
LongMath.checkedMultiply |
IntMath.checkedPow |
LongMath.checkedPow |
IntMath.checkedAdd(Integer.MAX_VALUE, Integer.MAX_VALUE); // throws ArithmeticException
Real-valued methods
java.math.RoundingMode
DOWN: round towards 0. (This is the behavior of Java division.)UP: round away from 0.FLOOR: round towards negative infinity.CEILING: round towards positive infinity.UNNECESSARY: rounding should not be necessary; if it is, fail fast by throwing an ArithmeticException.HALF_UP: round to the nearest half, rounding x.5 away from 0.HALF_DOWN: round to the nearest half, rounding x.5 towards 0.HALF_EVEN: round to the nearest half, rounding x.5 to its nearest even neighbor.