Skip to content

numfmt: apply prefix after scaling for --to-unit#11684

Merged
cakebaker merged 2 commits intouutils:mainfrom
BipulLamsal:fix-numfmt-to-unit-suffix-after-scaling
Apr 7, 2026
Merged

numfmt: apply prefix after scaling for --to-unit#11684
cakebaker merged 2 commits intouutils:mainfrom
BipulLamsal:fix-numfmt-to-unit-suffix-after-scaling

Conversation

@BipulLamsal
Copy link
Copy Markdown
Contributor

@BipulLamsal BipulLamsal commented Apr 6, 2026

Fixes #11666

Prefix selection was done before scaling, which caused incorrect results while using --to-unit.

This change moves prefix selection to occur after scaling, ensuring correct IEC/SI formatting.

Tested with:

./target/debug/numfmt --to=iec-i --to-unit=885 100000 => 113
./target/debug/numfmt --to=iec-i --to-unit=885 1000000 => 1.2Ki

@BipulLamsal BipulLamsal changed the title numfmt: apply suffix after scaling for --to-unit numfmt: apply prefix after scaling for --to-unit Apr 6, 2026
@sylvestre
Copy link
Copy Markdown
Contributor

please also remove the ignore for the test in 53c7d6f

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cp/link-heap is now passing!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/rm/isatty (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cp/link-heap is now passing!

@cakebaker cakebaker merged commit d2726f2 into uutils:main Apr 7, 2026
169 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks for your PR!

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: --to-unit uses unscaled value to pick SI/IEC prefix

3 participants