Java Reference
In-Depth Information
22.9.
Math
and
StrictMath
The
Math
class consists of static constants and methods for common
mathematical manipulations that use normal floating-point semantics.
The
StrictMath
class defines the same constants and methods but always
uses specific algorithms. This means that
StrictMath
methods always re-
turn the same values across different virtual machines, while
Math
meth-
ods are allowed to vary within specified limits. Both classes have two use-
ful
double
constants:
E
approximates
e
(2.7182818284590452354), and
PI
approximates
p
(3.14159265358979323846). In the following table of
the main
Math
and
StrictMath
methods, angles are in radians and all para-
meters and return values are
double
unless stated otherwise:
Function
Value
sine(
a
)
sin(a)
cosine(
a
)
cos(a)
tangent(
a
)
tan(a)
arcsine(
v
), with
v
in the range [1.0, 1.0]
asin(v)
arccosine(
v
), with
v
in the range [1.0, 1.0]
acos(v)
arctangent(
v
), returned in the range [
p
/2,
p
/2]
atan(v)
arctangent(
x/y
), returned in the range [
p
,
p
]
atan2(x,y)