-
Notifications
You must be signed in to change notification settings - Fork 414
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: decimal stat rounding overflow #2975
fix: decimal stat rounding overflow #2975
Conversation
ACTION NEEDED delta-rs follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
2bee4af
to
fbc8626
Compare
if (val.trunc() as i128).to_string().len() > (precision - scale) as usize { | ||
// For normal values with integer parts that get rounded to a number beyond | ||
// the precision - scale range take the next smaller (by magnitude) value | ||
val = f64::from_bits(val.to_bits() - 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.
Not sure how performant this is, but the result won't be consistent/parse-able without it.
The actual "round-down" could be done with next_down
once it's stable/delta-rs uses nightly.
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.
@rtyler would you be ok with having delta-rs use nightly features?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2975 +/- ##
=======================================
Coverage 72.47% 72.47%
=======================================
Files 128 128
Lines 40823 40857 +34
Branches 40823 40857 +34
=======================================
+ Hits 29585 29613 +28
- Misses 9355 9356 +1
- Partials 1883 1888 +5 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Signed-off-by: Marko Grujic <[email protected]>
66d926d
to
3012da5
Compare
Description
Try to detect the situation where floating point conversion rounds the integer value beyond the valid Decimal(scale, precision) range, and rollback to next smaller value towards 0.0.
Related Issue(s)
Closes #2974
Documentation
None