-
Notifications
You must be signed in to change notification settings - Fork 915
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
Fix rounding to zero error in stod on very small float numbers #10672
Fix rounding to zero error in stod on very small float numbers #10672
Conversation
Codecov Report
@@ Coverage Diff @@
## branch-22.06 #10672 +/- ##
================================================
+ Coverage 86.38% 86.41% +0.02%
================================================
Files 142 142
Lines 22334 22334
================================================
+ Hits 19294 19300 +6
+ Misses 3040 3034 -6
Continue to review full report at Codecov.
|
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.
Awesome. I’m so glad my subnormal analysis worked out. Thanks for this PR, I got to learn a lot while writing up the review. 😊
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.
LGTM (@bdice 🔥🔥🔥)
@gpucibot merge |
Fixes a rounding error on extremely small floating-point numbers in the range
1E-287 - 1E-307
. These values were incorrectly being rounded to zero due to the fix in #10622. The extra float operation removed in #10622 is necessary for values in this range to keep them from being converted to zero.The fix adds a check so the extra floating point operation is only used when the overall exponent falls below
std::numeric_limits<double>::min_exponent10
(which is-307
). TheToFloat64
gtest was also updated to include value in this range to ensure this error does not occur again.Additionally, the conversion now supports subnormal numbers that are very very small in the range of E-307 and E-324.