Java Math Methods

Java has a lot of Math methods that allow us to perform mathematical computations. In this reference page, you will find all the math methods available in Java. For example, if you need to get the square root of a number, use the sqrt() method.

Java Math abs()

returns the absolute value of a number

Java Math acos()

returns the arc cosine of the specified value

Java Math addExact()

adds the specified numbers and returns it

Java Math asin()

returns the arc sine of the specified argument

Java Math atan()

returns the inverse tangent function of a value

Java Math cos()

returns the cosine of the specified angle

Java Math sin()

returns the sine of the specified angle in radians

Java Math tan()

returns the tangent value of the specified angle

Java Math sinh()

returns the hyperbolic sine of the specified value

Java Math cosh()

returns hyperbolic cosine of the specified value

Java Math tanh()

returns hyperbolic tangent of the specified value

Java Math sqrt()

returns the square root of the specified number

Java Math cbrt()

returns the cube root of the specified number

Java Math pow()

returns first argument raised to power of second

Java Math subtractExact()

subtracts the specified numbers and returns it

Java Math multiplyExact()

multiplies the specified numbers and returns it

Java Math incrementExact()

adds 1 to the specified number and returns it

Java Math decrementExact()

subtracts 1 from specified number and returns it

Java Math negateExact()

negates the specified variable and returns it

Java Math toIntExact()

returns the int value from specified long argument

Java Math min()

returns the smaller value among the arguments

Java Math max()

returns the maximum value among the arguments

Java Math ceil()

rounds the specified value upward

Java Math floor()

rounds the specified value downward and returns it

Java Math round()

rounds the specified argument and returns it

Java Math toRadians()

converts angle from degree to radians

Java Math toDegrees()

converts angle from radians to degrees

Java Math atan2()

returns θ converting coordinates (x, y) to (r, θ)

Java Math copySign()

copies the sign of second argument to the first

Java Math exp()

returns e raised to power of given value

Java Math expm1()

returns e raised to power of given value minus 1

Java Math getExponent()

returns the unbiased exponent of specified number

Java Math hypot()

computes the hypotenuse of a right-angle triangle

Java Math IEEEremainder()

returns the remainder as per the IEEE 754 standard

Java Math log()

returns the natural logarithm of specified value

Java Math log10()

returns the base 10 logarithm of specified value

Java Math log1p()

returns natural logarithm of (specified value + 1)

Java Math nextAfter()

returns number adjacent to specified number

Java Math nextUp()

returns number greater than and adjacent to value

Java Math nextDown()

returns number less than and adjacent to the value

Java Math rint()

returns closest mathematical integer of the vaue

Java Math.random()

returns a random value between 0.0 and 1.0