java::lang::Math Class Reference

Inheritance diagram for java::lang::Math:

Inheritance graph
java::lang::Object
[legend]
Collaboration diagram for java::lang::Math:

Collaboration graph
java::lang::Object
[legend]

List of all members.


Detailed Description

The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

Unlike some of the numeric functions of class StrictMath, all implementations of the equivalent functions of class Math are not defined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strict reproducibility is not required.

By default many of the Math functions simply delegate to the equivalent functions in StrictMath for their implementations. Code generators are encouraged to use platform-specific native libraries or microprocessor instructions, where available, to provide higher-performance implementations of Math functions. Such higher-performance implementations still must conform to the specification for Math.

Author:
unascribed
Version:
1.50, 02/02/00
Since:
JDK1.0

Static Public Member Functions

static jdouble sin (jdouble a)
 Returns the trigonometric sine of an angle.
static jdouble cos (jdouble a)
 Returns the trigonometric cosine of an angle.
static jdouble tan (jdouble a)
 Returns the trigonometric tangent of an angle.
static jdouble asin (jdouble a)
 Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
static jdouble acos (jdouble a)
 Returns the arc cosine of an angle, in the range of 0.0 through pi.
static jdouble atan (jdouble a)
 Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
static jdouble toRadians (jdouble angdeg)
 Converts an angle measured in degrees to the equivalent angle measured in radians.
static jdouble toDegrees (jdouble angrad)
 Converts an angle measured in radians to the equivalent angle measured in degrees.
static jdouble exp (jdouble a)
 Returns the exponential number e (i.e., 2.718.
static jdouble log (jdouble a)
 Returns the natural logarithm (base e) of a double value.
static jdouble sqrt (jdouble a)
 Returns the correctly rounded positive square root of a double value.
static jdouble IEEEremainder (jdouble f1, jdouble f2)
 Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
static jdouble ceil (jdouble a)
 Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.
static jdouble floor (jdouble a)
 Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
static jdouble rint (jdouble a)
 Returns the double value that is closest in value to a and is equal to a mathematical integer.
static jdouble atan2 (jdouble a, jdouble b)
 Converts rectangular coordinates (ba) to polar (r, theta).
static jdouble pow (jdouble a, jdouble b)
 Returns of value of the first argument raised to the power of the second argument.
static jint round (jfloat a)
 Returns the closest int to the argument.
static jlong round (jdouble a)
 Returns the closest long to the argument.
static jint abs (jint a)
 Returns the absolute value of an int value.
static jlong abs (jlong a)
 Returns the absolute value of a long value.
static jfloat abs (jfloat a)
 Returns the absolute value of a float value.
static jdouble abs (jdouble a)
 Returns the absolute value of a double value.
static jint max (jint a, jint b)
 Returns the greater of two int values.
static jlong max (jlong a, jlong b)
 Returns the greater of two long values.
static jfloat max (jfloat a, jfloat b)
 Returns the greater of two float values.
static jdouble max (jdouble a, jdouble b)
 Returns the greater of two double values.
static jint min (jint a, jint b)
 Returns the smaller of two int values.
static jlong min (jlong a, jlong b)
 Returns the smaller of two long values.
static jfloat min (jfloat a, jfloat b)
 Returns the smaller of two float values.
static jdouble min (jdouble a, jdouble b)
 Returns the smaller of two double values.

Static Public Attributes

static const jdouble E
 The double value that is closer than any other to e, the base of the natural logarithms.
static const jdouble PI
 The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Member Function Documentation

static jdouble java::lang::Math::sin ( jdouble  a  )  [static]

Returns the trigonometric sine of an angle.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a an angle, in radians.
Returns:
the sine of the argument.

static jdouble java::lang::Math::cos ( jdouble  a  )  [static]

Returns the trigonometric cosine of an angle.

Special case:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a an angle, in radians.
Returns:
the cosine of the argument.

static jdouble java::lang::Math::tan ( jdouble  a  )  [static]

Returns the trigonometric tangent of an angle.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a an angle, in radians.
Returns:
the tangent of the argument.

static jdouble java::lang::Math::asin ( jdouble  a  )  [static]

Returns the arc sine of an angle, in the range of -pi/2 through pi/2.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a the double value whose arc sine is to be returned.
Returns:
the arc sine of the argument.

static jdouble java::lang::Math::acos ( jdouble  a  )  [static]

Returns the arc cosine of an angle, in the range of 0.0 through pi.

Special case:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a the double value whose arc cosine is to be returned.
Returns:
the arc cosine of the argument.

static jdouble java::lang::Math::atan ( jdouble  a  )  [static]

Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a the double value whose arc tangent is to be returned.
Returns:
the arc tangent of the argument.

static jdouble java::lang::Math::toRadians ( jdouble  angdeg  )  [static]

Converts an angle measured in degrees to the equivalent angle measured in radians.

Parameters:
angdeg an angle, in degrees
Returns:
the measurement of the angle angdeg in radians.
Since:
1.2

static jdouble java::lang::Math::toDegrees ( jdouble  angrad  )  [static]

Converts an angle measured in radians to the equivalent angle measured in degrees.

Parameters:
angrad an angle, in radians
Returns:
the measurement of the angle angrad in degrees.
Since:
1.2

static jdouble java::lang::Math::exp ( jdouble  a  )  [static]

Returns the exponential number e (i.e., 2.718.

..) raised to the power of a double value.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a a double value.
Returns:
the value ea, where e is the base of the natural logarithms.

static jdouble java::lang::Math::log ( jdouble  a  )  [static]

Returns the natural logarithm (base e) of a double value.

Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a a number greater than 0.0.
Returns:
the value ln a, the natural logarithm of a.

static jdouble java::lang::Math::sqrt ( jdouble  a  )  [static]

Returns the correctly rounded positive square root of a double value.

Special cases:

Otherwise, the result is the double value closest to the true mathetmatical square root of the argument value.

Parameters:
a a double value.
Returns:
the positive square root of a. If the argument is NaN or less than zero, the result is NaN.

static jdouble java::lang::Math::IEEEremainder ( jdouble  f1,
jdouble  f2 
) [static]

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.

The remainder value is mathematically equal to f1 - f2  n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument. Special cases:

Parameters:
f1 the dividend.
f2 the divisor.
Returns:
the remainder when f1 is divided by f2.

static jdouble java::lang::Math::ceil ( jdouble  a  )  [static]

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:

Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).

Parameters:
a a double value.
Returns:
the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.

static jdouble java::lang::Math::floor ( jdouble  a  )  [static]

Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.

Special cases:

Parameters:
a a double value.
Returns:
the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.

static jdouble java::lang::Math::rint ( jdouble  a  )  [static]

Returns the double value that is closest in value to a and is equal to a mathematical integer.

If two double values that are mathematical integers are equally close to the value of the argument, the result is the integer value that is even. Special cases:

Parameters:
a a double value.
Returns:
the closest double value to a that is equal to a mathematical integer.

static jdouble java::lang::Math::atan2 ( jdouble  a,
jdouble  b 
) [static]

Converts rectangular coordinates (ba) to polar (r, theta).

This method computes the phase theta by computing an arc tangent of a/b in the range of -pi to pi. Special cases:

A result must be within 2 ulps of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a a double value.
b a double value.
Returns:
the theta component of the point (rtheta) in polar coordinates that corresponds to the point (ba) in Cartesian coordinates.

static jdouble java::lang::Math::pow ( jdouble  a,
jdouble  b 
) [static]

Returns of value of the first argument raised to the power of the second argument.

Special cases:

(In the foregoing descriptions, a floating-point value is considered to be an integer if and only if it is a fixed point of the method ceil or, which is the same thing, a fixed point of the method floor. A value is a fixed point of a one-argument method if and only if the result of applying the method to the value is equal to the value.)

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a a double value.
b a double value.
Returns:
the value ab.

static jint java::lang::Math::round ( jfloat  a  )  [static]

Returns the closest int to the argument.

The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression:

(int)Math.floor(a + 0.5f)

Special cases:

Parameters:
a a float value.
Returns:
the value of the argument rounded to the nearest int value.
See also:
java.lang.Integer::MAX_VALUE

java.lang.Integer::MIN_VALUE

static jlong java::lang::Math::round ( jdouble  a  )  [static]

Returns the closest long to the argument.

The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long. In other words, the result is equal to the value of the expression:

(long)Math.floor(a + 0.5d)

Special cases:

Parameters:
a a double value.
Returns:
the value of the argument rounded to the nearest long value.
See also:
java.lang.Long::MAX_VALUE

java.lang.Long::MIN_VALUE

static jint java::lang::Math::abs ( jint  a  )  [static]

Returns the absolute value of an int value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Note that if the argument is equal to the value of Integer.MIN_VALUE, the most negative representable int value, the result is that same value, which is negative.

Parameters:
a an int value.
Returns:
the absolute value of the argument.
See also:
java.lang.Integer::MIN_VALUE

static jlong java::lang::Math::abs ( jlong  a  )  [static]

Returns the absolute value of a long value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Note that if the argument is equal to the value of Long.MIN_VALUE, the most negative representable long value, the result is that same value, which is negative.

Parameters:
a a long value.
Returns:
the absolute value of the argument.
See also:
java.lang.Long::MIN_VALUE

static jfloat java::lang::Math::abs ( jfloat  a  )  [static]

Returns the absolute value of a float value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

In other words, the result is equal to the value of the expression:

Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))

Parameters:
a a float value.
Returns:
the absolute value of the argument.

static jdouble java::lang::Math::abs ( jdouble  a  )  [static]

Returns the absolute value of a double value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

In other words, the result is equal to the value of the expression:

Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)

Parameters:
a a double value.
Returns:
the absolute value of the argument.

static jint java::lang::Math::max ( jint  a,
jint  b 
) [static]

Returns the greater of two int values.

That is, the result is the argument closer to the value of Integer.MAX_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a an int value.
b an int value.
Returns:
the larger of a and b.
See also:
java.lang.Long::MAX_VALUE

static jlong java::lang::Math::max ( jlong  a,
jlong  b 
) [static]

Returns the greater of two long values.

That is, the result is the argument closer to the value of Long.MAX_VALUE. If the argumens have the same value, the result is that same value.

Parameters:
a a long value.
b a long value.
Returns:
the larger of a and b.
See also:
java.lang.Long::MAX_VALUE

static jfloat java::lang::Math::max ( jfloat  a,
jfloat  b 
) [static]

Returns the greater of two float values.

That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.

Parameters:
a a float value.
b a float value.
Returns:
the larger of a and b.

static jdouble java::lang::Math::max ( jdouble  a,
jdouble  b 
) [static]

Returns the greater of two double values.

That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.

Parameters:
a a double value.
b a double value.
Returns:
the larger of a and b.

static jint java::lang::Math::min ( jint  a,
jint  b 
) [static]

Returns the smaller of two int values.

That is, the result the argument closer to the value of Integer.MIN_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a an int value.
b an int value.
Returns:
the smaller of a and b.
See also:
java.lang.Long::MIN_VALUE

static jlong java::lang::Math::min ( jlong  a,
jlong  b 
) [static]

Returns the smaller of two long values.

That is, the result is the argument closer to the value of Long.MIN_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a a long value.
b a long value.
Returns:
the smaller of a and b.
See also:
java.lang.Long::MIN_VALUE

static jfloat java::lang::Math::min ( jfloat  a,
jfloat  b 
) [static]

Returns the smaller of two float values.

That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.

Parameters:
a a float value.
b a float value.
Returns:
the smaller of a and b.

static jdouble java::lang::Math::min ( jdouble  a,
jdouble  b 
) [static]

Returns the smaller of two double values.

That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.

Parameters:
a a double value.
b a double value.
Returns:
the smaller of a and b.


Member Data Documentation

const jdouble java::lang::Math::E [static]

The double value that is closer than any other to e, the base of the natural logarithms.

const jdouble java::lang::Math::PI [static]

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:39 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3