Java Reference
In-Depth Information
TABLE 7-1
Some Predefined Mathematical Methods and Named Constants (continued)
class
Math
(Package:
java.lang
)
x
is of type
double
. Returns a value of type
double
, which is the
smallest integer value that is not less than
x
.
Example:
ceil(56.34)
returns the value
57.0
ceil(x)
x
is of type
double
. Returns
e
x
, where e is approximately
2.7182818284590455
.
Example:
exp(3)
returns the value
20.085536923187668
exp(x)
x
is of type
double
. Returns a value of type
double
, which is the
largest integer value less than
x
.
Example:
floor(65.78)
returns the value
65.0
floor(x)
x
is of type
double
. Returns a value of type
double
, which is the
natural logarithm (base e) of
x
.
Example:
log(2)
returns the value
0.6931471805599453
log(x)
x
is of type
double
. Returns a value of type
double
, which is the
common logarithm (base 10) of
x
.
Example:
log10(2)
returns the value
0.3010299956639812
log10(x)
Returns the larger of
x
and
y
.If
x
and
y
are of type
int
, it returns a
value of type
int
;if
x
and
y
are of type
long
, it returns a value of type
long
;if
x
and
y
are of type
float
, it returns a value of type
float
;
if
x
and
y
are of type
double
, it returns a value of type
double
.
Example:
max(15, 25)
returns the value
25
max(23.67, 14.28)
returns the value
23.67
max(45, 23.78)
returns the value
45.00
max(x, y)
Returns the smaller of
x
and
y
.If
x
and
y
are of type
int
, it returns a
value of type
int
;if
x
and
y
are of type
long
, it returns a value of type
long
;if
x
and
y
are of type
float
, it returns a value of type
float
;
if
x
and
y
are of type
double
, it returns a value of type
double
.
Example:
min(15, 25)
returns the value
15
min(23.67, 14.28)
returns the value
14.28
min(12, 34.78)
returns the value
12.00
min(x, y)
x
and
y
are of type
double
. Returns a value of type
double
,whichis
x
y
.
Example:
pow(2.0, 3.0)
returns the value
8.0
pow(4, 0.5)
returns the value
2.0
pow(x, y)
Returns a value that is the integer closest to
x
.
Example:
round(24.56)
returns the value
25
round(18.35)
returns the value
18
round(x)
Search WWH ::
Custom Search