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

Fix rounding to zero error in stod on very small float numbers #10672

Merged
merged 4 commits into from
Apr 23, 2022

Conversation

davidwendt
Copy link
Contributor

@davidwendt davidwendt commented Apr 15, 2022

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). The ToFloat64 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.

@davidwendt davidwendt added bug Something isn't working 3 - Ready for Review Ready for review by team libcudf Affects libcudf (C++/CUDA) code. strings strings issues (C++ and Python) non-breaking Non-breaking change labels Apr 15, 2022
@davidwendt davidwendt self-assigned this Apr 15, 2022
@davidwendt davidwendt requested a review from a team as a code owner April 15, 2022 18:57
@davidwendt davidwendt requested review from harrism and bdice April 15, 2022 18:57
@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #10672 (a10e432) into branch-22.06 (94a5d41) will increase coverage by 0.02%.
The diff coverage is n/a.

@@               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     
Impacted Files Coverage Δ
python/cudf/cudf/core/column/string.py 89.22% <0.00%> (+0.12%) ⬆️
python/cudf/cudf/core/groupby/groupby.py 91.72% <0.00%> (+0.22%) ⬆️
python/cudf/cudf/core/tools/datetimes.py 84.49% <0.00%> (+0.30%) ⬆️
python/cudf/cudf/core/column/lists.py 92.79% <0.00%> (+1.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94a5d41...a10e432. Read the comment docs.

@davidwendt davidwendt requested a review from bdice April 18, 2022 12:57
Copy link
Contributor

@bdice bdice left a 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. 😊

cpp/src/strings/convert/convert_floats.cu Outdated Show resolved Hide resolved
cpp/tests/strings/floats_tests.cpp Show resolved Hide resolved
Copy link
Member

@PointKernel PointKernel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (@bdice 🔥🔥🔥)

@davidwendt
Copy link
Contributor Author

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 5264f95 into rapidsai:branch-22.06 Apr 23, 2022
@davidwendt davidwendt deleted the stod-exp-min-check branch April 23, 2022 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change strings strings issues (C++ and Python)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants