-
Notifications
You must be signed in to change notification settings - Fork 5.8k
JDK-8301396: Port fdlibm expm1 to Java #12394
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
Conversation
👋 Welcome back darcy! A progress list of the required criteria for merging this PR into |
Webrevs
|
failures += testRange(x, Math.ulp(x), 1000); | ||
|
||
// ... and just below subnormal threshold ... | ||
x = Math.nextDown(Double.MIN_NORMAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x = Math.nextDown(Double.MIN_NORMAL); | |
x = Math.nextDown(Double.MIN_NORMAL); |
if (hx < 0x3FF0_A2B2) { /* and |x| < 1.5 ln2 */ | ||
if (xsb == 0) { | ||
hi = x - ln2_hi; | ||
lo = ln2_lo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lo = ln2_lo; | |
lo = ln2_lo; |
if (xsb == 0) { | ||
hi = x - ln2_hi; | ||
lo = ln2_lo; | ||
k = 1;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k = 1;} | |
k = 1; | |
} |
return 0.5*(x - e) - 0.5; | ||
} | ||
if (k == 1) { | ||
if(x < -0.25) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(x < -0.25) { | |
if (x < -0.25) { |
if(x < -0.25) { | ||
return -2.0*(e - (x + 0.5)); | ||
} else { | ||
return one + 2.0*(x - e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return one + 2.0*(x - e); | |
return one + 2.0*(x - e); |
|
||
hx = __HI(x); /* high word of x */ | ||
xsb = hx & 0x8000_0000; /* sign bit of x */ | ||
y = Math.abs(x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's align this variable too
y = Math.abs(x); | |
y = Math.abs(x); |
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ | ||
lo = t*ln2_lo; | ||
} | ||
x = hi - lo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x = hi - lo; | |
x = hi - lo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the close reading; pushed those suggestions along with some others.
With the corrections by @turbanoff LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
@jddarcy This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 18 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit 3449324.
Your commit was automatically rebased without conflicts. |
@jddarcy Are you planning a GC of unused functions in StrictMath.c too? (for this PR I'm wondering about Java_java_lang_StrictMath_expm1). |
Yes, once the port is done, I'll remove all the remaining FDLIBM C files. There are dependencies between the different C files, sinh calls expm1, etc., so to avoid needed to untangle all of those, I was going to do the removal in one step at the end. |
Next on the FDLIBM C -> Java port, expm1.
Coming soon, hyperbolic transcendentals (sinh, cosh, tanh)!
For expm1, the C vs transliteration port show the usual kind of differences, beside formatting of the constants, the use of the __HI macro on the left-hand side needs to be replaced by a method call and an assignment, as seen below:
When comparing the transliteration port and the more idiomatic port, there were no surprising or notable differences:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12394/head:pull/12394
$ git checkout pull/12394
Update a local copy of the PR:
$ git checkout pull/12394
$ git pull https://git.openjdk.org/jdk pull/12394/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12394
View PR using the GUI difftool:
$ git pr show -t 12394
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12394.diff