Math (Java SE 23 & JDK 23)
-
Field Summary
Fields
static final doubleThe
doublevalue that is closer than any other to e, the base of the natural logarithms.static final doubleThe
doublevalue that is closer than any other to pi (π), the ratio of the circumference of a circle to its diameter.static final doubleThe
doublevalue that is closer than any other to tau (τ), the ratio of the circumference of a circle to its radius. -
Method Summary
static doubleabs(double a) Returns the absolute value of a
doublevalue.static floatabs(float a) Returns the absolute value of a
floatvalue.static intabs(int a) Returns the absolute value of an
intvalue.static longabs(long a) Returns the absolute value of a
longvalue.static intabsExact(int a) Returns the mathematical absolute value of an
intvalue if it is exactly representable as anint, throwingArithmeticExceptionif the result overflows the positiveintrange.static longabsExact(long a) Returns the mathematical absolute value of an
longvalue if it is exactly representable as anlong, throwingArithmeticExceptionif the result overflows the positivelongrange.static doubleacos(double a) Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.
static intaddExact(int x, int y) Returns the sum of its arguments, throwing an exception if the result overflows an
int.static longaddExact(long x, long y) Returns the sum of its arguments, throwing an exception if the result overflows a
long.static doubleasin(double a) Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.
static doubleatan(double a) Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.
static doubleatan2(double y, double x) Returns the angle theta from the conversion of rectangular coordinates (
x,y) to polar coordinates (r, theta).static doublecbrt(double a) Returns the cube root of a
doublevalue.static doubleceil(double a) Returns the smallest (closest to negative infinity)
doublevalue that is greater than or equal to the argument and is equal to a mathematical integer.static intceilDiv(int x, int y) Returns the smallest (closest to negative infinity)
intvalue that is greater than or equal to the algebraic quotient.static longceilDiv(long x, int y) Returns the smallest (closest to negative infinity)
longvalue that is greater than or equal to the algebraic quotient.static longceilDiv(long x, long y) Returns the smallest (closest to negative infinity)
longvalue that is greater than or equal to the algebraic quotient.static intceilDivExact(int x, int y) Returns the smallest (closest to negative infinity)
intvalue that is greater than or equal to the algebraic quotient.static longceilDivExact(long x, long y) Returns the smallest (closest to negative infinity)
longvalue that is greater than or equal to the algebraic quotient.static intceilMod(int x, int y) Returns the ceiling modulus of the
intarguments.static intceilMod(long x, int y) Returns the ceiling modulus of the
longandintarguments.static longceilMod(long x, long y) Returns the ceiling modulus of the
longarguments.static doubleclamp(double value, double min, double max) Clamps the value to fit between min and max.
static floatclamp(float value, float min, float max) Clamps the value to fit between min and max.
static intclamp(long value, int min, int max) Clamps the value to fit between min and max.
static longclamp(long value, long min, long max) Clamps the value to fit between min and max.
static doublecopySign(double magnitude, double sign) Returns the first floating-point argument with the sign of the second floating-point argument.
static floatcopySign(float magnitude, float sign) Returns the first floating-point argument with the sign of the second floating-point argument.
static doublecos(double a) Returns the trigonometric cosine of an angle.
static doublecosh(double x) Returns the hyperbolic cosine of a
doublevalue.static intdecrementExact(int a) Returns the argument decremented by one, throwing an exception if the result overflows an
int.static longdecrementExact(long a) Returns the argument decremented by one, throwing an exception if the result overflows a
long.static intdivideExact(int x, int y) Returns the quotient of the arguments, throwing an exception if the result overflows an
int.static longdivideExact(long x, long y) Returns the quotient of the arguments, throwing an exception if the result overflows a
long.static doubleexp(double a) Returns Euler's number e raised to the power of a
doublevalue.static doubleexpm1(double x) static doublefloor(double a) Returns the largest (closest to positive infinity)
doublevalue that is less than or equal to the argument and is equal to a mathematical integer.static intfloorDiv(int x, int y) Returns the largest (closest to positive infinity)
intvalue that is less than or equal to the algebraic quotient.static longfloorDiv(long x, int y) Returns the largest (closest to positive infinity)
longvalue that is less than or equal to the algebraic quotient.static longfloorDiv(long x, long y) Returns the largest (closest to positive infinity)
longvalue that is less than or equal to the algebraic quotient.static intfloorDivExact(int x, int y) Returns the largest (closest to positive infinity)
intvalue that is less than or equal to the algebraic quotient.static longfloorDivExact(long x, long y) Returns the largest (closest to positive infinity)
longvalue that is less than or equal to the algebraic quotient.static intfloorMod(int x, int y) Returns the floor modulus of the
intarguments.static intfloorMod(long x, int y) Returns the floor modulus of the
longandintarguments.static longfloorMod(long x, long y) Returns the floor modulus of the
longarguments.static doublefma(double a, double b, double c) Returns the fused multiply add of the three arguments; that is, returns the exact product of the first two arguments summed with the third argument and then rounded once to the nearest
double.static floatfma(float a, float b, float c) Returns the fused multiply add of the three arguments; that is, returns the exact product of the first two arguments summed with the third argument and then rounded once to the nearest
float.static intgetExponent(double d) Returns the unbiased exponent used in the representation of a
double.static intgetExponent(float f) Returns the unbiased exponent used in the representation of a
float.static doublehypot(double x, double y) Returns sqrt(x2 +y2) without intermediate overflow or underflow.
static doubleIEEEremainder(double f1, double f2) Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
static intincrementExact(int a) Returns the argument incremented by one, throwing an exception if the result overflows an
int.static longincrementExact(long a) Returns the argument incremented by one, throwing an exception if the result overflows a
long.static doublelog(double a) Returns the natural logarithm (base e) of a
doublevalue.static doublelog10(double a) Returns the base 10 logarithm of a
doublevalue.static doublelog1p(double x) Returns the natural logarithm of the sum of the argument and 1.
static doublemax(double a, double b) Returns the greater of two
doublevalues.static floatmax(float a, float b) Returns the greater of two
floatvalues.static intmax(int a, int b) Returns the greater of two
intvalues.static longmax(long a, long b) Returns the greater of two
longvalues.static doublemin(double a, double b) Returns the smaller of two
doublevalues.static floatmin(float a, float b) Returns the smaller of two
floatvalues.static intmin(int a, int b) Returns the smaller of two
intvalues.static longmin(long a, long b) Returns the smaller of two
longvalues.static intmultiplyExact(int x, int y) Returns the product of the arguments, throwing an exception if the result overflows an
int.static longmultiplyExact(long x, int y) Returns the product of the arguments, throwing an exception if the result overflows a
long.static longmultiplyExact(long x, long y) Returns the product of the arguments, throwing an exception if the result overflows a
long.static longmultiplyFull(int x, int y) Returns the exact mathematical product of the arguments.
static longmultiplyHigh(long x, long y) Returns as a
longthe most significant 64 bits of the 128-bit product of two 64-bit factors.static intnegateExact(int a) Returns the negation of the argument, throwing an exception if the result overflows an
int.static longnegateExact(long a) Returns the negation of the argument, throwing an exception if the result overflows a
long.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 doublenextDown(double d) Returns the floating-point value adjacent to
din the direction of negative infinity.static floatnextDown(float f) Returns the floating-point value adjacent to
fin the direction of negative infinity.static doublenextUp(double d) Returns the floating-point value adjacent to
din the direction of positive infinity.static floatnextUp(float f) Returns the floating-point value adjacent to
fin the direction of positive infinity.static doublepow(double a, double b) Returns the value of the first argument raised to the power of the second argument.
static doublerandom()Returns a
doublevalue with a positive sign, greater than or equal to0.0and less than1.0.static doublerint(double a) Returns the
doublevalue that is closest in value to the argument and is equal to a mathematical integer.static longround(double a) Returns the closest
longto the argument, with ties rounding to positive infinity.static intround(float a) Returns the closest
intto the argument, with ties rounding to positive infinity.static doublescalb(double d, int scaleFactor) Returns
d× 2scaleFactorrounded as if performed by a single correctly rounded floating-point multiply.static floatscalb(float f, int scaleFactor) Returns
f× 2scaleFactorrounded as if performed by a single correctly rounded floating-point multiply.static doublesignum(double d) Returns the signum function of the argument; 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 function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.
static doublesin(double a) Returns the trigonometric sine of an angle.
static doublesinh(double x) Returns the hyperbolic sine of a
doublevalue.static doublesqrt(double a) Returns the correctly rounded positive square root of a
doublevalue.static intsubtractExact(int x, int y) Returns the difference of the arguments, throwing an exception if the result overflows an
int.static longsubtractExact(long x, long y) Returns the difference of the arguments, throwing an exception if the result overflows a
long.static doubletan(double a) Returns the trigonometric tangent of an angle.
static doubletanh(double x) Returns the hyperbolic tangent of a
doublevalue.static doubletoDegrees(double angrad) Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
static inttoIntExact(long value) Returns the value of the
longargument, throwing an exception if the value overflows anint.static doubletoRadians(double angdeg) Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
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.
static longunsignedMultiplyHigh(long x, long y) Returns as a
longthe most significant 64 bits of the unsigned 128-bit product of two unsigned 64-bit factors.
-
Field Details
-
E
-
PI
-
TAU
-
-
Method Details
-
sin
-
cos
-
tan
-
asin
-
acos
-
atan
-
toRadians
-
toDegrees
-
exp
-
log
-
log10
-
sqrt
-
cbrt
-
IEEEremainder
-
ceil
-
floor
-
rint
-
atan2
-
pow
-
round
-
round
-
random
-
addExact
-
addExact
-
subtractExact
-
subtractExact
-
multiplyExact
-
multiplyExact
-
multiplyExact
-
divideExact
-
divideExact
-
floorDivExact
-
floorDivExact
-
ceilDivExact
-
ceilDivExact
-
incrementExact
-
incrementExact
-
decrementExact
-
decrementExact
-
negateExact
-
negateExact
-
toIntExact
-
multiplyFull
-
multiplyHigh
-
unsignedMultiplyHigh
-
floorDiv
-
floorDiv
-
floorDiv
-
floorMod
-
floorMod
-
floorMod
-
ceilDiv
-
ceilDiv
-
ceilDiv
-
ceilMod
-
ceilMod
-
ceilMod
-
abs
-
absExact
-
abs
-
absExact
-
abs
-
abs
-
max
-
max
-
max
-
max
-
min
-
min
-
min
-
min
-
clamp
-
clamp
-
clamp
-
clamp
-
fma
-
fma
-
ulp
-
ulp
-
signum
-
signum
-
sinh
-
cosh
-
tanh
-
hypot
-
expm1
-
log1p
-
copySign
-
copySign
-
getExponent
-
getExponent
-
nextAfter
-
nextAfter
-
nextUp
-
nextUp
-
nextDown
-
nextDown
-
scalb
-
scalb
-