numfmt: fix rounding for small scaled values#12032
Merged
cakebaker merged 1 commit intoApr 27, 2026
Merged
Conversation
|
GNU testsuite comparison: |
b7b5f85 to
f0e1d70
Compare
Contributor
|
Thanks for your PR! |
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.
Summary
Fixes rounding for small scaled values when
numfmt --to=si/iec/iec-idoes not select a suffix.In this case GNU
numfmtappears to use display formatting rounding for the scaled value, while uutils was applying the configured rounding method directly. This caused cases like--to=si 0.4and--to=iec --to-unit=689 701to round away from GNU behavior.Changes
--to=nonerounding path unchanged.--to=si/iec/iec-ipath to match GNU display rounding behavior.--to-unit, and--formatprecision.Test plan
cargo fmtcargo test -p uu_numfmtcargo test --test tests test_numfmt::test_to_unitless_small_values_use_display_roundingcargo test --test tests test_numfmt::test_to_unit_with_unitless_small_value_uses_display_roundingcargo test --test tests test_numfmt::test_format_with_precision_and_unitless_to_argFixes #11938