java.lang
Class Math

java.lang.Object
  |
  +--java.lang.Math

public final class Math
extends Object

The standard Math library. For the methods in this Class, error handling for out-of-range or immeasurable results are platform dependent. This class cannot be subclassed or instantiated because all methods and variables are static.


Field Summary
static double E
          The float representation of the value E.
static double PI
          The float representation of the value Pi.
 
Method Summary
static double abs(double a)
          Returns the absolute double value of a.
static float abs(float a)
          Returns the absolute float value of a.
static int abs(int a)
          Returns the absolute integer value of a.
static long abs(long a)
          Returns the absolute long value of a.
static double acos(double a)
          Returns the arc cosine of a, in the range of 0.0 through Pi.
static double asin(double a)
          Returns the arc sine of a, in the range of -Pi/2 through Pi/2.
static double atan(double a)
          Returns the arc tangent of a, in the range of -Pi/2 through Pi/2.
static double atan2(double a, double b)
          Converts rectangular coordinates (a, b) to polar (r, theta).
static double ceil(double a)
          Returns the "ceiling" or smallest whole number greater than or equal to a.
static double cos(double a)
          Returns the trigonometric cosine of an angle.
static double exp(double a)
          Returns the exponential number e(2.718...) raised to the power of a.
static double floor(double a)
          Returns the "floor" or largest whole number less than or equal to a.
static double IEEEremainder(double f1, double f2)
          Returns the remainder of f1 divided by f2 as defined by IEEE 754.
static double log(double a)
          Returns the natural logarithm (base e) of a.
static double max(double a, double b)
          Takes two double values, a and b, and returns the greater number of the two.
static float max(float a, float b)
          Takes two float values, a and b, and returns the greater number of the two.
static int max(int a, int b)
          Takes two int values, a and b, and returns the greater number of the two.
static long max(long a, long b)
          Takes two long values, a and b, and returns the greater number of the two.
static double min(double a, double b)
          Takes two double values, a and b, and returns the smallest number of the two.
static float min(float a, float b)
          Takes two float values, a and b, and returns the smallest number of the two.
static int min(int a, int b)
          Takes two integer values, a and b, and returns the smallest number of the two.
static long min(long a, long b)
          Takes two long values, a and b, and returns the smallest number of the two.
static double pow(double a, double b)
          Returns the number a raised to the power of b.
static double random()
          Generates a random number between 0.0 and 1.0.
static double rint(double a)
          Converts a double value into an integral value in double format.
static long round(double a)
          Rounds off a double value by first adding 0.5 to it and then returning the largest integer that is less than or equal to this new value.
static int round(float a)
          Rounds off a float value by first adding 0.5 to it and then returning the largest integer that is less than or equal to this new value.
static double sin(double a)
          Returns the trigonometric sine of an angle.
static double sqrt(double a)
          Returns the square root of a.
static double tan(double a)
          Returns the trigonometric tangent of an angle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

E

public static final double E
The float representation of the value E. E is equivalent to 2.7182818284590452354f in Java.

See Also:
Constant Field Values

PI

public static final double PI
The float representation of the value Pi. Pi is equivalent to 3.14159265358979323846f in Java.

See Also:
Constant Field Values
Method Detail

sin

public static double sin(double a)
Returns the trigonometric sine of an angle.

Parameters:
a - an assigned angle that is measured in radians

cos

public static double cos(double a)
Returns the trigonometric cosine of an angle.

Parameters:
a - an assigned angle that is measured in radians

tan

public static double tan(double a)
Returns the trigonometric tangent of an angle.

Parameters:
a - an assigned angle that is measured in radians

asin

public static double asin(double a)
Returns the arc sine of a, in the range of -Pi/2 through Pi/2.

Parameters:
a - (-1.0) <= a <= 1.0

acos

public static double acos(double a)
Returns the arc cosine of a, in the range of 0.0 through Pi.

Parameters:
a - (-1.0) <= a <= 1.0

atan

public static double atan(double a)
Returns the arc tangent of a, in the range of -Pi/2 through Pi/2.

Parameters:
a - an assigned value
Returns:
the arc tangent of a.

exp

public static double exp(double a)
Returns the exponential number e(2.718...) raised to the power of a.

Parameters:
a - an assigned value

log

public static double log(double a)
Returns the natural logarithm (base e) of a.

Parameters:
a - a is a number greater than 0.0

sqrt

public static double sqrt(double a)
Returns the square root of a.

Parameters:
a - a is a number greater than or equal to 0.0

IEEEremainder

public static double IEEEremainder(double f1,
                                   double f2)
Returns the remainder of f1 divided by f2 as defined by IEEE 754.

Parameters:
f1 - the dividend
f2 - the divisor

ceil

public static double ceil(double a)
Returns the "ceiling" or smallest whole number greater than or equal to a.

Parameters:
a - an assigned value

floor

public static double floor(double a)
Returns the "floor" or largest whole number less than or equal to a.

Parameters:
a - an assigned value

rint

public static double rint(double a)
Converts a double value into an integral value in double format.

Parameters:
a - an assigned double value

atan2

public static double atan2(double a,
                           double b)
Converts rectangular coordinates (a, b) to polar (r, theta). This method computes the phase theta by computing an arc tangent of b/a in the range of -Pi to Pi.

Parameters:
a - an assigned value
b - an assigned value
Returns:
the polar coordinates (r, theta).

pow

public static double pow(double a,
                         double b)
Returns the number a raised to the power of b. If (a == 0.0), then b must be greater than 0.0; otherwise you will throw an exception. An exception will also occur if (a <= 0.0) and b is not equal to a whole number.

Parameters:
a - an assigned value with the exceptions: (a == 0.0) -> (b > 0.0) && (a <= 0.0) -> (b == a whole number)
b - an assigned value with the exceptions: (a == 0.0) -> (b > 0.0) && (a <= 0.0) -> (b == a whole number)
Throws:
ArithmeticException - If (a == 0.0) and (b <= 0.0) .
ArithmeticException - If (a <= 0.0) and b is not equal to a whole number.

round

public static int round(float a)
Rounds off a float value by first adding 0.5 to it and then returning the largest integer that is less than or equal to this new value.

Parameters:
a - the value to be rounded off

round

public static long round(double a)
Rounds off a double value by first adding 0.5 to it and then returning the largest integer that is less than or equal to this new value.

Parameters:
a - the value to be rounded off

random

public static double random()
Generates a random number between 0.0 and 1.0.

Random number generators are often referred to as pseudorandom number generators because the numbers produced tend to repeat themselves after a period of time.

Returns:
a pseudorandom double between 0.0 and 1.0.

abs

public static int abs(int a)
Returns the absolute integer value of a.

Parameters:
a - an assigned integer value

abs

public static long abs(long a)
Returns the absolute long value of a.

Parameters:
a - an assigned long value.

abs

public static float abs(float a)
Returns the absolute float value of a.

Parameters:
a - an assigned float value

abs

public static double abs(double a)
Returns the absolute double value of a.

Parameters:
a - an assigned double value

max

public static int max(int a,
                      int b)
Takes two int values, a and b, and returns the greater number of the two.

Parameters:
a - an integer value to be compared
b - an integer value to be compared

max

public static long max(long a,
                       long b)
Takes two long values, a and b, and returns the greater number of the two.

Parameters:
a - a long value to be compared
b - a long value to be compared

max

public static float max(float a,
                        float b)
Takes two float values, a and b, and returns the greater number of the two.

Parameters:
a - a float value to be compared
b - a float value to be compared

max

public static double max(double a,
                         double b)
Takes two double values, a and b, and returns the greater number of the two.

Parameters:
a - a double value to be compared
b - a double value to be compared

min

public static int min(int a,
                      int b)
Takes two integer values, a and b, and returns the smallest number of the two.

Parameters:
a - an integer value to be compared
b - an integer value to be compared

min

public static long min(long a,
                       long b)
Takes two long values, a and b, and returns the smallest number of the two.

Parameters:
a - a long value to be compared
b - a long value to be compared

min

public static float min(float a,
                        float b)
Takes two float values, a and b, and returns the smallest number of the two.

Parameters:
a - a float value to be compared
b - a float value to be compared

min

public static double min(double a,
                         double b)
Takes two double values, a and b, and returns the smallest number of the two.

Parameters:
a - a double value to be compared
b - a double value to be compared