Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math.pow results are expected to be the same in Hotspot #10918

Closed
darongmean opened this issue Oct 18, 2020 · 1 comment
Closed

Math.pow results are expected to be the same in Hotspot #10918

darongmean opened this issue Oct 18, 2020 · 1 comment

Comments

@darongmean
Copy link

Java -version output

openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.21.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20200715_677 (JIT enabled, AOT enabled)
OpenJ9   - 34cf4c075
OMR      - 113e54219
JCL      - 95bb504fbb based on jdk-11.0.8+10)

Summary of problem

Math.pow(3, 2.4) doesn't return the same result in Hotspot.

In OpenJ9,

jshell> Math.pow(3,2.4)
$1 ==> 13.966610165238237

In Hotspot,

jshell> Math.pow(3,2.4)
$1 ==> 13.966610165238235

More discussion at https://openj9.slack.com/archives/C862YFGL9/p1602903053006700

@fjeremic
Copy link
Contributor

fjeremic commented Oct 19, 2020

I think @pshipton's comment in the Slack thread is key here, which I will quote:

Actually, it's Hotspot that has the "incorrect" answer, although this is allowed by the spec. Using StrictMath, the answer is 13.966610165238237 on both OpenJ9 and Hotspot.

"Unlike some of the numeric methods of class StrictMath, all implementations of the equivalent functions of class Math are not defined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strict reproducibility is not required."

This does not look like a bug, but rather a difference allowed by the Java spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants