Math API Reference
Java Math class — methods for basic numeric operations.
Math
The Math class contains methods for performing basic numeric operations.
static int abs(int a)Return the absolute value of an int. Long.MIN_VALUE remains negative.
Returns: int
static int max(int a, int b)Return the greater of two int values.
Returns: int
static int min(int a, int b)Return the smaller of two int values.
Returns: int
static double pow(double a, double b)Return the value of a raised to the power of b.
Returns: double
static double sqrt(double a)Return the correctly rounded positive square root of a. NaN if a < 0.
Returns: double
static long round(double a)Return the closest long to a, with ties rounding to positive infinity.
Returns: long
static double ceil(double a)Return the smallest (closest to negative infinity) double that is greater than or equal to a and equal to a mathematical integer.
Returns: double
static double floor(double a)Return the largest (closest to positive infinity) double that is less than or equal to a and equal to a mathematical integer.
Returns: double
static double random()Return a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
Returns: double