Skip to content

fix: carry display rounding into the next unit with and without std - #217

Merged
robjtede merged 2 commits into
masterfrom
fix-display-rounding-no-std
Nov 25, 2026
Merged

robjtede merged 2 commits into
masterfrom
fix-display-rounding-no-std

Conversation

@robjtede

Copy link
Copy Markdown
Member

Fixes #212.

Mradul Singh (@bardrop) wrote the display rounding fix and regression tests in #213. This PR includes his original commit (408d7e5). For example, 1,048,575 bytes now displays as 1.0 MiB at the default precision.

The follow-up commit replaces f64::powi with division so the same rounding check works with --no-default-features. The loop stops once additional decimal places can no longer change the threshold.

Local checks passed with just check and just test.

bardrop and others added 2 commits November 20, 2026 07:24
1,048,575 B is 1023.999 KiB and was shown as "1024.0 KiB". After
picking the unit, check whether the value rounds to a whole unit at the
requested precision and, if so, show it in the next unit ("1.0 MiB").

Fixes #212
@codspeed

codspeed Bot commented Nov 25, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.03%

⚡ 4 improved benchmarks
✅ 26 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Walltime parse_bytesize[1.5 GiB] 98 ns 83 ns +18.07%
⚡ Walltime parse_bytesize[42 MB] 91 ns 78 ns +16.67%
⚡ Walltime parse_bytesize[42 MiB] 90 ns 84 ns +7.14%
⚡ Walltime deserialize_json["42 KiB"] 143 ns 134 ns +6.72%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix-display-rounding-no-std (eb4dd98) with master (dd34f8c)

Open in CodSpeed

@robjtede
robjtede added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit 24e6eb0 Nov 25, 2026
13 checks passed
@robjtede
robjtede deleted the fix-display-rounding-no-std branch November 25, 2026 02:50
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.

Display shows "1024.0 KiB" instead of "1.0 MiB" when the value rounds up

2 participants