class Math (Package: java.lang)
Example:
abs(-67) returns the value 67
abs(35) returns the value 35
abs(-75.38) returns the value 75.38
ceil(x)
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
exp(x)
x is of type double. Returns ex, where e is approximately
2.7182818284590455.
Example: exp(3) returns the value 20.085536923187668
floor(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
log(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
log10(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
max(x, y)
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
min(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
pow(x, y)
x and y are of type double. Returns a value of type double, which is xy.
Example: pow(2.0, 3.0) returns the value 8.0
pow(4, 0.5) returns the value 2.0
round(x)
Returns a value which is the integer closest to x.
Example: round(24.56) returns the value 25
round(18.35) returns the value 18
No comments:
Post a Comment