Math class contains the exponential, logarithm, square root, and trigonometric functions.
Constant E and PI
Type | Field | Summary |
---|---|---|
static double | E | base of the natural logarithms. |
static double | PI | pi. |
Get the absolute value
Return | Method | Summary |
---|---|---|
static double | abs(double a) | Returns the absolute value of a double value. |
static float | abs(float a) | Returns the absolute value of a float value. |
static int | abs(int a) | Returns the absolute value of an int value. |
static long | abs(long a) | Returns the absolute value of a long value. |
sin, cos, tan: Trigonometric functions
Return | Method | Summary |
---|---|---|
static double | acos(double a) | Returns the arc cosine of a value. |
static double | asin(double a) | Returns the arc sine of a value. |
static double | atan(double a) | Returns the arc tangent of a value. |
static double | atan2(double y, double x) | Returns the angle theta. |
static double | cos(double a) | Returns the trigonometric cosine of an angle. |
static double | cosh(double x) | Returns the hyperbolic cosine of a double value. |
static double | sin(double a) | Returns the trigonometric sine of an angle. |
static double | sinh(double x) | Returns the hyperbolic sine of a double value. |
static double | tan(double a) | Returns the trigonometric tangent of an angle. |
static double | tanh(double x) | Returns the hyperbolic tangent of a double value. |
Cube root and square root
Return | Method | Summary |
---|---|---|
static double | cbrt(double a) | Returns the cube root. |
static double | sqrt(double a) | Returns the square root of a double value. |
Ceilling and flooring value
Return | Method | Summary |
---|---|---|
static double | ceil(double a) | Returns the smallest double value that is greater than or equal to a and is equal to an integer. |
static double | floor(double a) | Returns the largest double value that is less than or equal to the argument and is equal to an integer. |
Copy sign
Return | Method | Summary |
---|---|---|
static double | copySign(double magnitude, double s) | Returns the first floating-point argument with the sign of s. |
static float | copySign(float magnitude, float s) | Returns the first floating-point argument with the sign of s. |
Raise the power
Return | Method | Summary |
---|---|---|
static double | exp(double a) | Raise to the power of a double value. |
static double | expm1(double x) | Returns ex -1. |
static double | pow(double a, double b) | a raised to the power b. |
Get exponent
Return | Method | Summary |
---|---|---|
static int | getExponent(double d) | Returns the exponent for a double. |
static int | getExponent(float f) | Returns the exponent for a float. |
sqrt(x2 +y2)
Return | Method | Summary |
---|---|---|
static double | hypot(double x, double y) | Returns sqrt(x2 +y2) . |
IEEE remainder
Return | Method | Summary |
---|---|---|
static double | IEEEremainder(double f1, double f2) | Computes the remainder operation on two arguments by the IEEE 754 standard. |
logarithm
Return | Method | Summary |
---|---|---|
static double | log(double a) | Returns the natural logarithm (base e) of a double value. |
static double | log10(double a) | Returns the base 10 logarithm of a double value. |
static double | log1p(double x) | Returns the natural logarithm of the sum of the argument and 1. |
Max min value
Return | Method | Summary |
---|---|---|
static double | max(double a, double b) | Returns the greater of two double values. |
static float | max(float a, float b) | Returns the greater of two float values. |
static int | max(int a, int b) | Returns the greater of two int values. |
static long | max(long a, long b) | Returns the greater of two long values. |
static double | min(double a, double b) | Returns the smaller of two double values. |
static float | min(float a, float b) | Returns the smaller of two float values. |
static int | min(int a, int b) | Returns the smaller of two int values. |
static long | min(long a, long b) | Returns the smaller of two long values. |
Next value
Return | Method | Summary |
---|---|---|
static double | nextAfter(double start, double direction) | Returns the floating-point number adjacent to the first argument in the direction of the second argument. |
static float | nextAfter(float start, double direction) | Returns the floating-point number adjacent to the first argument in the direction of the second argument. |
static double | nextUp(double d) | Returns the floating-point value adjacent to d in the direction of positive infinity. |
static float | nextUp(float f) | Returns the floating-point value adjacent to f in the direction of positive infinity. |
Random
Return | Method | Summary |
---|---|---|
static double | random() | Returns a random double value between 0.0 and 1.0. |
Round to int
Return | Method | Summary |
---|---|---|
static double | rint(double a) | Returns the double value that is closest to a and is equal to an integer. |
Round a value
Return | Method | Summary |
---|---|---|
static long | round(double a) | Returns the closest long to a. |
static int | round(float a) | Returns the closest int to a. |
value * 2^ scaleFactor
Return | Method | Summary |
---|---|---|
static double | scalb(double d, int scaleFactor) | Return d * 2<sup>scaleFactor</sup>. |
static float | scalb(float f, int scaleFactor) | Return f * 2<sup>scaleFactor</sup>. |
Get the sign
Return | Method | Summary |
---|---|---|
static double | signum(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 float | signum(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
Return | Method | Summary |
---|---|---|
static double | toDegrees(double angrad) | Converts an angle in radians to an angle measured in degrees. |
static double | toRadians(double angdeg) | Converts an angle in degrees to an angle measured in radians. |
Returns the size of an ulp of the argument
Return | Method | Summary |
---|---|---|
static double | ulp(double d) | Returns the size of an ulp of the argument. |
static float | ulp(float f) | Returns the size of an ulp of the argument. |
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. |