Skip to content

numfmt: preserve fractional digits when --from-unit is used without suffix and fixed String format#11674

Merged
cakebaker merged 3 commits intouutils:mainfrom
Eshwar1440:fix/numfmt-from-unit-fractional-precision
Apr 6, 2026
Merged

numfmt: preserve fractional digits when --from-unit is used without suffix and fixed String format#11674
cakebaker merged 3 commits intouutils:mainfrom
Eshwar1440:fix/numfmt-from-unit-fractional-precision

Conversation

@Eshwar1440
Copy link
Copy Markdown
Contributor

Fix #11663

When from-unit multiplies a fractional input with no unit suffix, uutils was rounding the result to an integer instead of preserving the fractional digits as GNU does.

Fixes conducted by making two changes in format.rs:

  1. Skipped ceiling in transform_from when input has no unit suffix.
  2. Used input implicit precision in format_string when not converting to a unit system.

Removed #[ignore] from the existing test so that all tests now pass.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

GNU testsuite comparison:

GNU test failed: tests/numfmt/numfmt. tests/numfmt/numfmt is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/expand/bounded-memory is now being skipped but was previously passing.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!
Congrats! The gnu test tests/unexpand/bounded-memory is now passing!

@cakebaker cakebaker merged commit 79c90ff into uutils:main Apr 6, 2026
169 of 170 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks for your PR!

@Eshwar1440 Eshwar1440 deleted the fix/numfmt-from-unit-fractional-precision branch April 6, 2026 13:14
kevinburkesegment pushed a commit to kevinburkesegment/coreutils that referenced this pull request Apr 6, 2026
…uffix and fixed String format (uutils#11674)

* numfmt: preserve fractional digits when --from-unit is used without suffix and fixed String format

* numfmt: simplify redundant if branches caught by clippy

* numfmt: fix precision condition to only preserve decimals when input has no unit suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

numfmt: --from-unit with fractional input rounds to integer, GNU preserves fraction

2 participants