Skip to content

numfmt: round a suffixed input with --round instead of always up - #16685

Open
Xnadir wants to merge 2 commits into
uutils:mainfrom
Xnadir:numfmt-round-suffix
Open

Xnadir wants to merge 2 commits into
uutils:mainfrom
Xnadir:numfmt-round-suffix

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

A number read with a suffix was rounded up to a whole number as soon as it was parsed, so numfmt --from=si --round=down --format=%.0f 0.0625K printed 63 and --format=%.1f printed 63.0, while GNU prints 62 and 62.5, as for 62.5. transform_from now keeps the fraction and leaves the rounding to --round and the output precision.

The new test covers the issue's commands with down, up and towards-zero, with and without a format; it fails on main. With --to=si, a value below the first suffix is still printed half-to-even instead of with --round (#15574); #15636 fixes that part, so I left it out here.

Closes #16672

AI disclosure: written with help from Claude Code.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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: --round=down rounds 0.0625K up to 63 but rounds 62.5 down to 62

2 participants