Section
9 : The java.lang Package
Write
code using the following methods of the java.lang.Math
class: abs, ceil, floor, max, min, random, round, sin,
cos, tan, sqrt.
Math
It is a
final class having a
private constructor. All of its methods are
static.
Fields:

static
double E

static
double PI
Methods:
type is
double,
float,
int and
long. Return type and
argument type are same. In case of
int and
long versions, if
respective MIN_VALUE is the argument then same is
returned. In case of float and
double versions if argument is positive or
negative zero, positive zero is returned. If argument
is infinite, positive Infinity is returned. If
argument is NaN, the result is NaN.
returns
the smallest (closest to negative infinity)
double value that is not
less than the argument and is equal to a mathematical
integer. Special cases:
If
argument is equal to an integer, same is returned.
If
argument is NaN, +Infinity, Infinity, +0, or –0, the
result is same as argument.
If
argument is less than zero but greater than –1.0,
result is –0.0
returns
the largest (closest to positive infinity)
double value that is not
greater than the argument and is equal to mathematical
integer.
Return
values are same in special cases as that in ceil()
except there is no third case.
d is in
radians. If argument is NaN or infinity, result is
NaN.
type is
int,
float,
long or
double. Return type is
same as argument type. Returns the greater of the two
values. For float and double
versions:
if
either of the arguments is NaN, NaN is returned.
Unlike
the numerical comparison operators, here –0.0 is
smaller than +0.0
returns
the smaller of the two values. Rest of the discussion
is same as max().
returns
double value between +0.0
and 1.0 (exclusive). This method is properly
synchronized to allow correct use by more than one
thread.
returns
the closest double value
to argument and is equal to an integer.
return
the closest long value to
the argument.
If
argument is NaN, result is zero.
If
argument is –Infinity or any value less than or equal
to the value of Long.MIN_VALUE, the result is equal to
Long.MIN_VALUE.
If
argument is +Infinity or >= Long.MAX_VALUE, then the
result is Long.MAX_VALUE.
return
the closest long or
int values to the
argument respectively.
If
argument is NaN, result is zero.
If
argument is –Infinity or any value less than or equal
to the value of Integer.MIN_VALUE, the result is equal
to Integer.MIN_VALUE.
If
argument is +Infinity or >= Integer.MAX_VALUE, then
the result is Integer.MAX_VALUE.
returns
the correctly rounded positive square root of a
double value.
If the
argument is NaN or less than zero, then the result is
NaN.
If the
argument is positive infinity, then the result is
positive infinity.
If the
argument is positive or negative zero, then the result
is same as the argument.
d is in
radians. If argument is NaN or infinity, result is
NaN.
same as
sin().
section91  section92
Sections :
1  2  3  4  5  6  7  8  9  10  11
