JDK-8240632 : Note differences between IEEE 754-2019 math lib special cases and java.lang.Math
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-03-05
  • Updated: 2022-04-22
  • Resolved: 2021-02-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b09Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Relates :  
Description
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.
Comments
Changeset: 2fd8ed02 Author: Joe Darcy <darcy@openjdk.org> Date: 2021-02-08 21:50:55 +0000 URL: https://git.openjdk.java.net/jdk/commit/2fd8ed02
08-02-2021