The result of Math.log(3.0) is different on x86_64 and aarch64?
joe.darcy at oracle.com
Mon Jul 29 18:16:25 UTC 2019
On 7/29/2019 7:44 AM, Andrew Dinn wrote:
> On 29/07/2019 15:25, Martin Buchholz wrote:
>> I was surprised to see the doc of Math.log make it explicit:
>> """The computed result must be within 1 ulp of the exact result. Results
>> must be semi-monotonic."""
> Yes, indeed. I had to look up semi-monotonic even though I really ought
> to have known what it meant :-)
> Anyway, there is no surprise really once you correlate the thoroughness
> of that documentation (and the rest ...) with the inestimably efficient
> purring of the engine that is Joe Darcy's brain. This is one area that
> really can be nailed down by spec and it is very nice to see that it has
To give credit where it is due, before I joined the JDK group way back
in JDK 1.3 Tim Lindholm added the changes to address
JDK-4245947: "Resolve tension between performance and
reproducibility in Math class"
I had input on the changes and IIRC Prof. Kahan provided some guidance
as well. The "Improving Java for Numerical Computation" report  from
the Java Grande numerics working group circa 1998 also called for
updates to the math library to allow high-performance results as well as
reproducible results. The solution was to introduce a new class,
java.lang.StrictMath to provide operational reproduciblity and to
re-define the java.lang.Math class to allow any algorithm that met the
stated quality of implementation criteria. A consequence of that
implementation flexibility is that for many methods of java.lang.Math it
is *not* required that the same value be returned for the same input
across different implementations.
More information about the jdk-dev