For various math library functions, there are multiple plausible behaviors in some special cases. Starting with IEEE 754-2008 and continuing with IEEE 754-2019, the standard makes recommendations for handling those special values. In some of the special cases, the IEEE recommendations do not match the pre-existing behavior defined for java.lang.Math and java.lang.StrictMath. The java.lang.{Math, StrictMath} classes both long predate the floating-point standard to provide recommendations for the math library.
These differences, and other notable ties to IEEE 754-2019 should be noted in the specification of java.lang.Math.
The differences include:
* cos(0.0) = 1.0
* exp(0.0) = 1.0
* acos(1.0) = 0.0
* acos((+/- infinity) = pi/2
* log(1.0) => 0.0
* log10(1.0) => 0.0
* hypot(+/-0, +/-0) => +0.0
The Math/StrictMath implementations are expected to conform to most of these behaviors, but the current specification doesn't explicitly require them too.
These differences, and other notable ties to IEEE 754-2019 should be noted in the specification of java.lang.Math.
The differences include:
* cos(0.0) = 1.0
* exp(0.0) = 1.0
* acos(1.0) = 0.0
* acos((+/- infinity) = pi/2
* log(1.0) => 0.0
* log10(1.0) => 0.0
* hypot(+/-0, +/-0) => +0.0
The Math/StrictMath implementations are expected to conform to most of these behaviors, but the current specification doesn't explicitly require them too.
- csr for
-
JDK-8261116 Note differences between IEEE 754-2019 math lib special cases and java.lang.Math
-
- Closed
-
- relates to
-
JDK-8285384 Math.exp(1.0) has different result on aarch64 vs x86
-
- Closed
-
-
JDK-8240624 Note mapping of RoundingMode constants to equivalent IEEE 754-2019 policy
-
- Resolved
-
-
JDK-8257086 Clarify differences between {Float, Double}.equals and ==
-
- Resolved
-
(1 links to)