Repository navigation
Conversation
…ng first applyPrecisionHandling() only moved to the next unit when toPrecision() returned e-notation. Since avoidwork#404 the value is no longer rounded to `round` before the precision pass, so 999.999 kB with precision 4 gives "1000" and printed "1000 kB" (filesize(999999) prints "1 MB"). Move up when the significant-digit form reaches `ceil` too. When the unit moved, the recomputed value was still rounded to `round` decimals before toPrecision(), the same double rounding avoidwork#399 fixed in the main path: 1000 KiB printed "0.980 MiB" instead of "0.977 MiB", and with round: 0, 392 B at precision 1 printed "0 kB". Take the new value straight from the input; roundingFunc and round are no longer needed here. Fixes avoidwork#413
Owner
|
I think i'm going to roll back the recent changes as they are incomplete. |
Only add the unit ceiling check; restore the rounding step and its parameters, as requested in review.
Author
|
Fair point, sorry about that. I pushed 3c8efc3, which puts If you roll back #404 instead, that also fixes the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
applyPrecisionHandling()now also moves to the next unit whentoPrecision()reaches the unit ceiling, not only on e-notation.Since #404,
(999.999).toPrecision(4)is"1000", which has noe, sofilesize(999999, { precision: 4 })printed1000 kB(and1048575withbase: 2printed1024 KiB). It now prints1.000 MB/1.000 MiB, as 11.0.30 did and asfilesize(999999)→1 MBdoes.The helper signature,
roundingFunc,roundand the rounding step are unchanged (an earlier version of this PR removed them; that is reverted after review).Type of Change
Related Issues
Fixes #413
Testing
Precision option(ceiling bump for SI / IEC / bits / negative / object and exponent output / forced exponent). It fails on master (1000 kB) and passes with the fix.npm test: lint clean, 280 pass / 0 fail, coverage still 100% for all files.Checklist
npm testpassesnpm run buildsucceeds