# Math class

Math class contains the exponential, logarithm, square root, and trigonometric functions.

`static double E`
base of the natural logarithms.
`static double PI`
pi.
`abs(double a)`
Returns the absolute value of a double value.
`abs(float a)`
Returns the absolute value of a float value.
`abs(int a)`
Returns the absolute value of an int value.
`abs(long a)`
Returns the absolute value of a long value.
`acos(double a)`
Returns the arc cosine of a value.
`asin(double a)`
Returns the arc sine of a value.
`atan(double a)`
Returns the arc tangent of a value.
`atan2(double y, double x)`
Returns the angle theta.
`cbrt(double a)`
Returns the cube root.
`ceil(double a)`
Returns the smallest double value that is greater than or equal to a and is equal to an integer.
`copySign(double magnitude, double s)`
Returns the first floating-point argument with the sign of s.
`copySign(float magnitude, float s)`
Returns the first floating-point argument with the sign of s.
`cos(double a)`
Returns the trigonometric cosine of an angle.
`cosh(double x)`
Returns the hyperbolic cosine of a double value.
`exp(double a)`
Raise to the power of a double value.
`expm1(double x)`
Returns ex -1.
`floor(double a)`
Returns the largest double value that is less than or equal to the argument and is equal to an integer.
`getExponent(double d)`
Returns the exponent for a double.
`getExponent(float f)`
Returns the exponent for a float.
`hypot(double x, double y)`
Returns sqrt(x2 +y2) .
`IEEEremainder(double f1, double f2)`
Computes the remainder operation on two arguments by the IEEE 754 standard.
`log(double a)`
Returns the natural logarithm (base e) of a double value.
`log10(double a)`
Returns the base 10 logarithm of a double value.
`log1p(double x)`
Returns the natural logarithm of the sum of the argument and 1.
`max(double a, double b)`
Returns the greater of two double values.
`max(float a, float b)`
Returns the greater of two float values.
`max(int a, int b)`
Returns the greater of two int values.
`max(long a, long b)`
Returns the greater of two long values.
`min(double a, double b)`
Returns the smaller of two double values.
`min(float a, float b)`
Returns the smaller of two float values.
`min(int a, int b)`
Returns the smaller of two int values.
`min(long a, long b)`
Returns the smaller of two long values.
`nextAfter(double start, double direction)`
Returns the floating-point number adjacent to the first argument in the direction of the second argument.
`nextAfter(float start, double direction)`
Returns the floating-point number adjacent to the first argument in the direction of the second argument.
`nextUp(double d)`
Returns the floating-point value adjacent to d in the direction of positive infinity.
`nextUp(float f)`
Returns the floating-point value adjacent to f in the direction of positive infinity.
`pow(double a, double b)`
a raised to the power b.
`random()`
Returns a random double value between 0.0 and 1.0.
`rint(double a)`
Returns the double value that is closest to a and is equal to an integer.
`round(double a)`
Returns the closest long to a.
`round(float a)`
Returns the closest int to a.
`scalb(double d, int scaleFactor)`
Return d * 2<sup>scaleFactor</sup>.
`scalb(float f, int scaleFactor)`
Return f * 2<sup>scaleFactor</sup>.
`signum(double d)`
Returns the sign of d; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
`signum(float f)`
Returns the signum of f; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.
`sin(double a)`
Returns the trigonometric sine of an angle.
`sinh(double x)`
Returns the hyperbolic sine of a double value.
`sqrt(double a)`
Returns the square root of a double value.
`tan(double a)`
Returns the trigonometric tangent of an angle.
`tanh(double x)`
Returns the hyperbolic tangent of a double value.
`toDegrees(double angrad)`
Converts an angle in radians to an angle measured in degrees.
`toRadians(double angdeg)`
Converts an angle in degrees to an angle measured in radians.
`ulp(double d)`
Returns the size of an ulp of the argument.
`ulp(float f)`
Returns the size of an ulp of the argument.

Revised from Open JDK source code

Home
Java Book
Essential Classes

Math: