Math class

Math class contains the exponential, logarithm, square root, and trigonometric functions.

Constant E and PI

TypeFieldSummary
static doubleEbase of the natural logarithms.
static doublePIpi.

Get the absolute value

ReturnMethodSummary
static doubleabs(double a)Returns the absolute value of a double value.
static floatabs(float a)Returns the absolute value of a float value.
static intabs(int a)Returns the absolute value of an int value.
static longabs(long a)Returns the absolute value of a long value.

sin, cos, tan: Trigonometric functions

ReturnMethodSummary
static doubleacos(double a)Returns the arc cosine of a value.
static doubleasin(double a)Returns the arc sine of a value.
static doubleatan(double a)Returns the arc tangent of a value.
static doubleatan2(double y, double x)Returns the angle theta.
static doublecos(double a)Returns the trigonometric cosine of an angle.
static doublecosh(double x)Returns the hyperbolic cosine of a double value.
static doublesin(double a)Returns the trigonometric sine of an angle.
static doublesinh(double x)Returns the hyperbolic sine of a double value.
static doubletan(double a)Returns the trigonometric tangent of an angle.
static doubletanh(double x)Returns the hyperbolic tangent of a double value.

Cube root and square root

ReturnMethodSummary
static doublecbrt(double a)Returns the cube root.
static doublesqrt(double a)Returns the square root of a double value.

Ceilling and flooring value

ReturnMethodSummary
static doubleceil(double a)Returns the smallest double value that is greater than or equal to a and is equal to an integer.
static doublefloor(double a)Returns the largest double value that is less than or equal to the argument and is equal to an integer.

Copy sign

ReturnMethodSummary
static doublecopySign(double magnitude, double s)Returns the first floating-point argument with the sign of s.
static floatcopySign(float magnitude, float s)Returns the first floating-point argument with the sign of s.

Raise the power

ReturnMethodSummary
static doubleexp(double a)Raise to the power of a double value.
static doubleexpm1(double x)Returns ex -1.
static doublepow(double a, double b)a raised to the power b.

Get exponent

ReturnMethodSummary
static intgetExponent(double d)Returns the exponent for a double.
static intgetExponent(float f)Returns the exponent for a float.

sqrt(x2 +y2)

ReturnMethodSummary
static doublehypot(double x, double y)Returns sqrt(x2 +y2) .

IEEE remainder

ReturnMethodSummary
static doubleIEEEremainder(double f1, double f2)Computes the remainder operation on two arguments by the IEEE 754 standard.

logarithm

ReturnMethodSummary
static doublelog(double a)Returns the natural logarithm (base e) of a double value.
static doublelog10(double a)Returns the base 10 logarithm of a double value.
static doublelog1p(double x)Returns the natural logarithm of the sum of the argument and 1.

Max min value

ReturnMethodSummary
static doublemax(double a, double b)Returns the greater of two double values.
static floatmax(float a, float b)Returns the greater of two float values.
static intmax(int a, int b)Returns the greater of two int values.
static longmax(long a, long b)Returns the greater of two long values.
static doublemin(double a, double b)Returns the smaller of two double values.
static floatmin(float a, float b)Returns the smaller of two float values.
static intmin(int a, int b)Returns the smaller of two int values.
static longmin(long a, long b)Returns the smaller of two long values.

Next value

ReturnMethodSummary
static doublenextAfter(double start, double direction)Returns the floating-point number adjacent to the first argument in the direction of the second argument.
static floatnextAfter(float start, double direction)Returns the floating-point number adjacent to the first argument in the direction of the second argument.
static doublenextUp(double d)Returns the floating-point value adjacent to d in the direction of positive infinity.
static floatnextUp(float f)Returns the floating-point value adjacent to f in the direction of positive infinity.

Random

ReturnMethodSummary
static doublerandom()Returns a random double value between 0.0 and 1.0.

Round to int

ReturnMethodSummary
static doublerint(double a)Returns the double value that is closest to a and is equal to an integer.

Round a value

ReturnMethodSummary
static longround(double a)Returns the closest long to a.
static intround(float a)Returns the closest int to a.

value * 2^ scaleFactor

ReturnMethodSummary
static doublescalb(double d, int scaleFactor) Return d * 2<sup>scaleFactor</sup>.
static floatscalb(float f, int scaleFactor) Return f * 2<sup>scaleFactor</sup>.

Get the sign

ReturnMethodSummary
static doublesignum(double d)Returns the sign of d; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
static floatsignum(float f)Returns the signum of f; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.

Degree to Radian, and Radian to Degree

ReturnMethodSummary
static doubletoDegrees(double angrad)Converts an angle in radians to an angle measured in degrees.
static doubletoRadians(double angdeg)Converts an angle in degrees to an angle measured in radians.

Returns the size of an ulp of the argument

ReturnMethodSummary
static doubleulp(double d)Returns the size of an ulp of the argument.
static floatulp(float f)Returns the size of an ulp of the argument.
Revised from Open JDK source code
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.