Math.exp() yields different results on 32 bit systems
Andreas Ahlenstorf
andreas at ahlenstorf.ch
Tue Sep 22 10:30:42 UTC 2020
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
More information about the core-libs-dev
mailing list