Round a subnormal product or quotient only once - #1474
Merged
Merged
Conversation
- In the default rounding mode, the divide of decimal32_t, decimal64_t and decimal128_t, and the multiply of decimal64_t, rounded the wide result to the precision of the type first. - For a subnormal result, pack_in_range then gave that value to the constructor, which rounded it again to the smallest exponent. The result could be one unit away from the correctly rounded value. - The finalizers now compare the result exponent with etiny_v first. Below it, the divide gives the constructor the quotient with one more digit, which is 1 when the remainder is not zero. The multiply gives the exact product. - The fast types flush these results to zero, so the guard is not in their code.
ibmibmibm
force-pushed
the
worktree-subnormal-round
branch
from
September 28, 2026 05:19
73528ef to
897162f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1474 +/- ##
=========================================
+ Coverage 98.6% 98.6% +0.1%
=========================================
Files 307 308 +1
Lines 25703 25727 +24
Branches 2205 2205
=========================================
+ Hits 25338 25364 +26
+ Misses 365 363 -2
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
ibmibmibm
marked this pull request as ready for review
September 28, 2026 08:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
decimal32_t,decimal64_tanddecimal128_t, andthe multiply of
decimal64_t, rounded the wide result to the precision of the typefirst. For a subnormal result, the constructor then rounded that value again to the
smallest exponent. Some results were one unit away from the correct value.
etiny_vfirst. Below it, thedivide gives the constructor the quotient with one more digit. If the remainder is not
zero, this digit is 1. The multiply gives the exact product. The constructor then
rounds once.
pack_in_rangecall. The fast typesflush these results to zero, thus the guard is not in their code.
github_issue_1473.cppchecks 12 subnormal quotients and products. All 12fail before the change.
After the change, a sweep of subnormal products and quotients gives no wrong result in
the five rounding modes. The time of the multiply and the divide changes by less than 5
percent. Issue #1473 gives the values, the sweep, the comparison with
developand thebenchmark.
Fixes #1473