Java Math 方法

Java Math 类有许多方法,可以让您对数字执行数学计算。

所有 Math 方法


abs(x)Returns the absolute value of xdouble|float|int|long
acos(x)Returns the arccosine of x, in radiansdouble
asin(x)Returns the arcsine of x, in radiansdouble
atan(x)Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radiansdouble
atan2(y,x)Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).double
cbrt(x)Returns the cube root of xdouble
ceil(x)Returns the value of x rounded up to its nearest integerdouble
copySign(x, y)Returns the first floating point x with the sign of the second floating point ydouble
cos(x)Returns the cosine of x (x is in radians)double
cosh(x)Returns the hyperbolic cosine of a double valuedouble
exp(x)Returns the value of Exdouble
expm1(x)Returns ex -1double
floor(x)Returns the value of x rounded down to its nearest integerdouble
getExponent(x)Returns the unbiased exponent used in xint
hypot(x, y)Returns sqrt(x2 +y2) without intermediate overflow or underflowdouble
IEEEremainder(x, y)Computes the remainder operation on x and y as prescribed by the IEEE 754 standarddouble
log(x)Returns the natural logarithm (base E) of xdouble
log10(x)Returns the base 10 logarithm of xdouble
log1p(x)Returns the natural logarithm (base E) of the sum of x and 1double
max(x, y)Returns the number with the highest valuedouble|float|int|long
min(x, y)Returns the number with the lowest valuedouble|float|int|long
nextAfter(x, y)Returns the floating point number adjacent to x in the direction of ydouble|float
nextUp(x)Returns the floating point value adjacent to x in the direction of positive infinitydouble|float
pow(x, y)Returns the value of x to the power of ydouble
random()Returns a random number between 0 and 1double
round(x)Returns the value of x rounded to its nearest integerint
rint()Returns the double value that is closest to x and equal to a mathematical integerdouble
signum(x)Returns the sign of xdouble
sin(x)Returns the sine of x (x is in radians)double
sinh(x)Returns the hyperbolic sine of a double valuedouble
sqrt(x)Returns the square root of xdouble
tan(x)Returns the tangent of an angledouble
tanh(x)Returns the hyperbolic tangent of a double valuedouble
toDegrees(x)Converts an angle measured in radians to an approx. equivalent angle measured in degreesdouble
toRadians(x)Converts an angle measured in degrees to an approx. angle measured in radiansdouble
ulp(x)Returns the size of the unit of least precision (ulp) of xdouble|float