Commit 56f4f71
committed
Fix metric() showing an extra significant digit on rounding carry
metric() derives the number of decimal places from the mantissa's
exponent, assuming the mantissa keeps its digit count. When rounding
carries it up a power of ten (9.999 -> 10.0, 99.99 -> 100) it gains an
integer digit and shows one significant figure too many, e.g.
metric(9999) returned '10.00 k' instead of '10.0 k'. The existing guard
only handled the mantissa reaching 1000 (a full SI-bucket crossing).
Detect the carry against the next power of ten and bump the exponent by
one, which recomputes the decimal places and, when the mantissa reaches
1000, still crosses into the next bucket exactly as before.1 parent c3a124c commit 56f4f71
2 files changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | | - | |
552 | | - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
261 | 270 | | |
262 | 271 | | |
263 | 272 | | |
| |||
0 commit comments