Package java.lang
Class Math
- java.lang.Object
-
- java.lang.Math
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleabs(double d)Returns the absolute value of the argument.static floatabs(float f)Returns the absolute value of the argument.static intabs(int i)Returns the absolute value of the argument.static longabs(long l)Returns the absolute value of the argument.static doubleacos(double x)Returns the arc cosinus of an angle in radiansstatic doubleatan(double arg)Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.static doubleatan2(double arg1, double arg2)Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.static intceil(float x)Round toward positive infinitystatic doublecos(double arg)Returns the trigonometric cosine of an angle.static intfix(float x)Round toward zerostatic intfloor(float x)Round toward negative infinitystatic doublelog(double d)Returns the closest double approximation of the natural logarithm of the argument.static doublelog(double d, double base)Returns the closest double approximation of the logarithm to a certain base.static doublelog10(double d)Returns the closest double approximation of the base 10 logarithm of the argument.static doublemax(double a, double b)Returns maximum valuestatic intmax(int i1, int i2)Returns the most positive (closest to positive infinity) of the two arguments.static longmax(long l1, long l2)Returns the most positive (closest to positive infinity) of the two arguments.static doublemin(double a, double b)Returns minimum valuestatic intmin(int i1, int i2)Returns the most negative (closest to negative infinity) of the two arguments.static longmin(long l1, long l2)Returns the most negative (closest to negative infinity) of the two arguments.static doublepowIntExp(double base, int exp)Calculation of power with exponent being an integer valuestatic doublerandom()Returns a pseudo-random doublen, wheren >= 0.0 && n < 1.0.static doublesin(double arg)Returns the trigonometric sine of an angle.static doublesqrt(double arg)Calculates square root.static doubletan(double arg)Returns the trigonometric tangent of an angle.static doubletoDegrees(double angrad)Returns the measure in degrees of the supplied radian angle.static doubletoRadians(double angdeg)Returns the measure in radians of the supplied degree angle.
-
-
-
Field Detail
-
E
public static final double E
The double value closest to e, the base of the natural logarithm.- See Also:
- Constant Field Values
-
PI
public static final double PI
The double value closest to pi, the ratio of a circle's circumference to its diameter.- See Also:
- Constant Field Values
-
-
Method Detail
-
powIntExp
public static double powIntExp(double base, int exp)Calculation of power with exponent being an integer value- Parameters:
base- baseexp- exponent- Returns:
- power baseexp.
-
log
public static double log(double d, double base)Returns the closest double approximation of the logarithm to a certain base. The returned result is within 1 ulp (unit in the last place) of the real result.- Parameters:
d- the value whose log has to be computed.base- the base to which the logarith is computed.- Returns:
- the natural logarithm of the argument.
-
log
public static double log(double d)
Returns the closest double approximation of the natural logarithm of the argument. The returned result is within 1 ulp (unit in the last place) of the real result.- Parameters:
d- the value whose log has to be computed.- Returns:
- the natural logarithm of the argument.
-
log10
public static double log10(double d)
Returns the closest double approximation of the base 10 logarithm of the argument. The returned result is within 1 ulp (unit in the last place) of the real result.- Parameters:
d- the value whose base 10 log has to be computed.- Returns:
- the natural logarithm of the argument.
-
abs
public static double abs(double d)
Returns the absolute value of the argument.Special cases:
abs(-0.0) = +0.0abs(+infinity) = +infinityabs(-infinity) = +infinityabs(NaN) = NaN
- Parameters:
d- Input value.- Returns:
- Absolute value.
-
abs
public static float abs(float f)
Returns the absolute value of the argument.Special cases:
abs(-0.0) = +0.0abs(+infinity) = +infinityabs(-infinity) = +infinityabs(NaN) = NaN
- Parameters:
f- Input value.- Returns:
- Absolute value.
-
abs
public static int abs(int i)
Returns the absolute value of the argument.If the argument is
Integer.MIN_VALUE,Integer.MIN_VALUEis returned.- Parameters:
i- Input value.- Returns:
- Absolute value.
-
abs
public static long abs(long l)
Returns the absolute value of the argument. If the argument isLong.MIN_VALUE,Long.MIN_VALUEis returned.- Parameters:
l- Input value.- Returns:
- Absolute value.
-
max
public static int max(int i1, int i2)Returns the most positive (closest to positive infinity) of the two arguments.- Parameters:
i1- First value.i2- Second value.- Returns:
- Maximum of the two input values.
-
max
public static long max(long l1, long l2)Returns the most positive (closest to positive infinity) of the two arguments.- Parameters:
l1- First value.l2- Second value.- Returns:
- Maximum of the two input values.
-
max
public static double max(double a, double b)Returns maximum value- Parameters:
a- First value.b- Second value.- Returns:
- Maximum of the two input values.
-
min
public static int min(int i1, int i2)Returns the most negative (closest to negative infinity) of the two arguments.- Parameters:
i1- First value.i2- Second value.- Returns:
- Minimum of the two input values.
-
min
public static long min(long l1, long l2)Returns the most negative (closest to negative infinity) of the two arguments.- Parameters:
l1- First value.l2- Second value.- Returns:
- Minimum of the two input values.
-
min
public static double min(double a, double b)Returns minimum value- Parameters:
a- First value.b- Second value.- Returns:
- Minimum of the two input values.
-
sqrt
public static double sqrt(double arg)
Calculates square root.- Parameters:
arg- Input value- Returns:
- square root
-
cos
public static double cos(double arg)
Returns the trigonometric cosine of an angle. Special cases:- If the argument is NaN or an infinity, then the result is NaN.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
- Parameters:
arg- an angle, in radians.- Returns:
- the cosine of the argument.
-
sin
public static double sin(double arg)
Returns the trigonometric sine of an angle. Special cases:- If the argument is NaN or an infinity, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
- Parameters:
arg- an angle, in radians.- Returns:
- the sine of the argument.
-
tan
public static double tan(double arg)
Returns the trigonometric tangent of an angle. Special cases:- If the argument is NaN or an infinity, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
- Parameters:
arg- an angle, in radians.- Returns:
- the tangent of the argument.
-
atan
public static double atan(double arg)
Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. Special cases:- If the argument is NaN, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
- Parameters:
arg- the value whose arc tangent is to be returned.- Returns:
- the arc tangent of the argument.
-
atan2
public static double atan2(double arg1, double arg2)Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
arctan(arg1/arg2) is calculated considering signs of the inputs
Special cases:
If both arguments are zero, NaN is returned- Parameters:
arg1- Nominatorarg2- Denominator- Returns:
- the arc tangent of the argument
-
acos
public static double acos(double x)
Returns the arc cosinus of an angle in radians- Parameters:
x- the value whose arc cosinus is to be returned- Returns:
- the arc cosinus of the argument
-
fix
public static int fix(float x)
Round toward zero- Parameters:
x- value to round- Returns:
- rounded value
-
ceil
public static int ceil(float x)
Round toward positive infinity- Parameters:
x- value to round- Returns:
- rounded value
-
floor
public static int floor(float x)
Round toward negative infinity- Parameters:
x- value to round- Returns:
- rounded value
-
random
public static double random()
Returns a pseudo-random doublen, wheren >= 0.0 && n < 1.0. This method reuses a single instance ofRandom. This method is thread-safe because access to theRandomis synchronized, but this harms scalability. Applications may find a performance benefit from allocating aRandomfor each of their threads.- Returns:
- a pseudo-random number.
-
toRadians
public static double toRadians(double angdeg)
Returns the measure in radians of the supplied degree angle. The result isangdeg / 180 * pi.Special cases:
toRadians(+0.0) = +0.0toRadians(-0.0) = -0.0toRadians(+infinity) = +infinitytoRadians(-infinity) = -infinitytoRadians(NaN) = NaN
- Parameters:
angdeg- an angle in degrees.- Returns:
- the radian measure of the angle.
-
toDegrees
public static double toDegrees(double angrad)
Returns the measure in degrees of the supplied radian angle. The result isangrad * 180 / pi.Special cases:
toDegrees(+0.0) = +0.0toDegrees(-0.0) = -0.0toDegrees(+infinity) = +infinitytoDegrees(-infinity) = -infinitytoDegrees(NaN) = NaN
- Parameters:
angrad- an angle in radians.- Returns:
- the degree measure of the angle.
-
-