bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math Methods

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Java Math Methods?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

The Java Math class has many methods that allows you to perform mathematical tasks on numbers.

All Math Methods

A list of all Math methods can be found in the table below:

MethodDescriptionReturn Type
abs(x)Returns the absolute value of xdoublefloatintlong
acos(x)Returns the arccosine of x, in radiansdouble
addExact(x, y)Returns the sum of x and yintlong
asin(x)Returns the arcsine of x, in radiansdouble
atan(x)Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radiansdouble
atan2(y,x)Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).double
cbrt(x)Returns the cube root of xdouble
ceil(x)Returns the value of x rounded up to its nearest integerdouble
copySign(x, y)Returns the first floating point x with the sign of the second floating point ydoublefloat
cos(x)Returns the cosine of x (x is in radians)double
cosh(x)Returns the hyperbolic cosine of a double valuedouble
decrementExact(x)Returns x-1intlong
exp(x)Returns the value of E xdouble
expm1(x)Returns e x -1double
floor(x)Returns the value of x rounded down to its nearest integerdouble
floorDiv(x, y)Returns the division between x and y rounded downintlong
floorMod(x, y)Returns the remainder of a division between x and y where the result of the division was rounded downintlong
getExponent(x)Returns the unbiased exponent used in xint
hypot(x, y)Returns sqrt(x 2 +y 2 ) without intermediate overflow or underflowdouble
IEEEremainder(x, y)Computes the remainder operation on x and y as prescribed by the IEEE 754 standarddouble
incrementExact(x)Returns x+1intdouble
log(x)Returns the natural logarithm (base E) of xdouble
log10(x)Returns the base 10 logarithm of xdouble
log1p(x)Returns the natural logarithm (base E) of the sum of x and 1double
max(x, y)Returns the number with the highest valuedoublefloatintlong
min(x, y)Returns the number with the lowest valuedoublefloatintlong
multiplyExact(x, y)Returns the result of x multiplied with yintlong
negateExact(x)Returns the negation of xintlong
pow(x, y)Returns the value of x to the power of ydouble
random()Returns a random number between 0 and 1double
rint(x)Returns the double value that is closest to x and equal to a mathematical integerdouble
round(x)Returns the value of x rounded to its nearest integerlongint
scalb(x, y)Returns x multiplied by 2 to the power of ydoublefloat
signum(x)Returns the sign of xdoublefloat
sin(x)Returns the sine of x (x is in radians)double
sinh(x)Returns the hyperbolic sine of a double valuedouble
sqrt(x)Returns the square root of xdouble
subtractExact(x, y)Returns the result of x minus yintlong
tan(x)Returns the tangent of an angledouble
tanh(x)Returns the hyperbolic tangent of a double valuedouble
toDegrees(x)Converts an angle measured in radians to an approx. equivalent angle measured in degreesdouble
toIntExact(x)Converts a long value to an intint
toRadians(x)Converts an angle measured in degrees to an approx. angle measured in radiansdouble
ulp(x)Returns the size of the unit of least precision (ulp) of xdoublefloat

Note

All Math methods are static .

Previous

Java String valueOf() Method

Next

Java Math abs() Method