2/11/25, 3:19 PM Java Math Reference
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Java Math Methods
❮ Previous Next ❯
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:
Method Description Return Type
abs(x) Returns the absolute value of x double|float|int|long
acos(x) Returns the arccosine of x, in radians double
addExact(x, y) Returns the sum of x and y int|long
asin(x) Returns the arcsine of x, in radians double
atan(x) Returns the arctangent of x as a double
numeric value between -PI/2 and PI/2
radians
atan2(y,x) Returns the angle theta from the double
conversion of rectangular coordinates
(x, y) to polar coordinates (r, theta).
cbrt(x) Returns the cube root of x double
ceil(x) Returns the value of x rounded up to double
its nearest integer
[Link] 1/7
2/11/25, 3:19 PM Java Math Reference
copySign(x,
Tutorialsy) Returns the first floating point x
Exercises Services with
the sign of the second floating point y
double|float
Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
cos(x) Returns the cosine of x (x is in double
radians)
cosh(x) Returns the hyperbolic cosine of a double
double value
decrementExact(x) Returns x-1 int|long
exp(x) Returns the value of Ex double
expm1(x) Returns ex -1 double
floor(x) Returns the value of x rounded down double
to its nearest integer
floorDiv(x, y) Returns the division between x and y int|long
rounded down
floorMod(x, y) Returns the remainder of a division int|long
between x and y where the result of
the division was rounded down
getExponent(x) Returns the unbiased exponent used in int
x
hypot(x, y) Returns sqrt(x2 +y2) without double
intermediate overflow or underflow
IEEEremainder(x, Computes the remainder operation on double
y) x and y as prescribed by the IEEE 754
standard
incrementExact(x) Returns x+1 int|double
log(x) Returns the natural logarithm (base E) double
of x
log10(x) Returns the base 10 logarithm of x double
log1p(x) Returns the natural logarithm (base E) double
of the sum of x and 1
max(x, y) Returns the number with the highest double|float|int|long
value
[Link] 2/7
2/11/25, 3:19 PM Java Math Reference
min(x,Tutorials
y)
Returns the number with the lowest
Exercises
value
Services double|float|int|long
Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
multiplyExact(x, y) Returns the result of x multiplied with int|long
y
negateExact(x) Returns the negation of x int|long
nextAfter(x, y) Returns the floating point number double|float
adjacent to x in the direction of y
nextDown(x) Returns the floating point value double|float
adjacent to x in the negative direction
nextUp(x) Returns the floating point value double|float
adjacent to x in the direction of
positive infinity
pow(x, y) Returns the value of x to the power of double
y
random() Returns a random number between 0 double
and 1
rint(x) Returns the double value that is double
closest to x and equal to a
mathematical integer
round(x) Returns the value of x rounded to its long|int
nearest integer
scalb(x, y) Returns x multiplied by 2 to the power double|float
of y
signum(x) Returns the sign of x double|float
sin(x) Returns the sine of x (x is in radians) double
sinh(x) Returns the hyperbolic sine of a double double
value
sqrt(x) Returns the square root of x double
subtractExact(x, Returns the result of x minus y int|long
y)
tan(x) Returns the tangent of an angle double
[Link] 3/7
2/11/25, 3:19 PM Java Math Reference
tanh(x)Tutorials Returns the hyperbolic tangent of
Exercises Services
double value
a double
Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
toDegrees(x) Converts an angle measured in radians double
to an approx. equivalent angle
measured in degrees
toIntExact(x) Converts a long value to an int int
toRadians(x) Converts an angle measured in double
degrees to an approx. angle measured
in radians
ulp(x) Returns the size of the unit of least double|float
precision (ulp) of x
Note: All Math methods are static .
Related Pages
Java Math Tutorial
❮ Previous Next ❯
Track your progress - it's free! Sign Up Log in
[Link] 4/7
2/11/25, 3:19 PM Java Math Reference
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
COLOR PICKER
PLUS SPACES GET CERTIFIED
FOR TEACHERS FOR BUSINESS CONTACT US
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
[Link] 5/7
2/11/25, 3:19 PM Java Math Reference
C++ Tutorial
jQuery Tutorial
Tutorials
Top References
Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT ACADEMY
W3Schools is optimized for learning and training. Examples might be simplified to
improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our
terms of use, cookie and privacy policy.
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by
[Link] 6/7
2/11/25, 3:19 PM Java Math Reference
[Link].
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
[Link] 7/7