Java Reference
In-Depth Information
static int abs ( int num)
Returns the absolute value of num.
static double acos ( double num)
static double asin ( double num)
static double atan ( double num)
Returns the arc cosine, arc sine, or arc tangent of num.
static double cos ( double angle)
static double sin ( double angle)
static double tan ( double angle)
Returns the angle cosine, sine, or tangent of angle, which is measured in
radians.
static double ceil ( double num)
Returns the ceiling of num, which is the smallest whole number greater than or
equal to num.
static double exp ( double power)
Returns the value e raised to the specified power.
static double floor ( double num)
Returns the floor of num, which is the largest whole number less than or equal
to num.
static double pow ( double num, double power)
Returns the value num raised to the specified power.
static double random ()
Returns a random number between 0.0 (inclusive) and 1.0 (exclusive).
static double sqrt ( double num)
Returns the square root of num, which must be positive.
FIGURE 3.5 Some methods of the Math class
Note that this program assumes that the discriminant (the value under the
square root) is negative. If it's not negative, the results will not be a valid number,
which Java represents as NAN , which stands for Not A Number. In Chapter 5 we
will see how we can handle this type of situation gracefully.
Search WWH ::




Custom Search