java.lang · java.base · since Java 1.0
Math
public final class MathStatic numeric toolbox: min/max/abs, powers and roots, trigonometry, rounding, and the *Exact family that makes integer overflow throw instead of wrap.
Key methods
static int/long/double max(a, b) / min(a, b) / abs(a) | The everyday trio (abs(MIN_VALUE) still overflows — absExact throws). |
static double pow(double, double) / sqrt(double) | Powers and roots. |
static long round(double) | Half-up rounding to long. |
static double floor/ceil(double) | Directional rounding, returns double. |
static int addExact/subtractExact/multiplyExact(int, int) | Throw ArithmeticException on overflow. |
static int toIntExact(long) | Checked narrowing. |
static int floorMod(int x, int y) | Non-negative modulo for cyclic indexing. |
static double random() | Uniform [0,1) — prefer ThreadLocalRandom for ranges. |