Math.exp() yields different results on 32 bit systems

Andrew Haley aph at redhat.com
Wed Sep 23 09:32:53 UTC 2020


On 22/09/2020 22:56, Joe Darcy wrote:
>
> Per the spec
>
> https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/Math.html#exp(double)
>
> the result of exp has to be within one ulp of the exact result and the
> value of e^(10_000) is (much) larger than Double.MAX_VALUE so positive
> infinity is the correct answer. Therefore, it looks like the intrinsic
> on 32-bit systems is buggy.

Indeed it does. It's going to be painful to fix because, as the
comment says, the intrinsic was generated by "Intel C compiler for
LIBM library" and is almost completely uncommented assembly code.

The sensible thing to do would be to go back to Intel and ask for a
fix. Alternatively, if someone wants to step through and find where it
all goes wrong...

Or we could just go back to the slightly-slower-but-correct libm
version.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the core-libs-dev mailing list