MathUtils

Added in 1.1.0

public class MathUtils


A utility class providing functions useful for common mathematical operations.

Summary

Public methods

static int
addExact(int x, int y)

Returns the sum of its arguments, throwing an exception if the result overflows an int.

static long
addExact(long x, long y)

Returns the sum of its arguments, throwing an exception if the result overflows a long.

static double
clamp(double value, double min, double max)

This method takes a numerical value and ensures it fits in a given numerical range.

static float
clamp(float value, float min, float max)

This method takes a numerical value and ensures it fits in a given numerical range.

static int
clamp(int value, int min, int max)

This method takes a numerical value and ensures it fits in a given numerical range.

static long
clamp(long value, long min, long max)

This method takes a numerical value and ensures it fits in a given numerical range.

static int

Returns the argument decremented by one, throwing an exception if the result overflows an int.

static long

Returns the argument decremented by one, throwing an exception if the result overflows a long.

static int

Returns the argument incremented by one, throwing an exception if the result overflows an int.

static long

Returns the argument incremented by one, throwing an exception if the result overflows a long.

static int
multiplyExact(int x, int y)

Returns the product of the arguments, throwing an exception if the result overflows an int.

static long
<c