Hello,
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.
HTH,
-Joe
On 9/22/2020 3:30 AM, Andreas Ahlenstorf wrote:
Hi!
According to a bug report at AdoptOpenJDK [1] Math.exp(10_000.0) yields
different results on 32 bit systems than on 64 bit systems.
public class Test {
public static void main(String[] args) {
System.out.println(Math.exp(10_000.0));
}
}
On 64 bit systems the code above prints Infinity. On 32 bit systems the result
is 0.0. I think that's wrong, but I'm far from an expert in floating point
arithmetics.
Affected versions:
* OpenJDK 9.0.1
* OpenJDK 11.0.8
* OpenJDK 15
Not affected:
* OpenJDK 8u265
We tested both with AdoptOpenJDK and Azul Zulu on Windows and Linux on x86 and
x64. If we disable intrinsics (-XX:+UnlockDiagnosticVMOptions
-XX:-UseLibmIntrinsic), Infinity is printed on x86 systems, too.
Is this expected behavior?
Best,
Andreas
[1] https://github.com/AdoptOpenJDK/openjdk-support/issues/182