fix: do not round non-zero values down to zero#264
Open
dkryaklin wants to merge 1 commit into
Open
Conversation
ludofischer
approved these changes
Jul 21, 2026
ludofischer
left a comment
Collaborator
There was a problem hiding this comment.
Could you explain the goal of this change? Right now I don't understand what's going on.
|
|
||
| test( | ||
| 'should not round a non-zero value down to zero', | ||
| testValue('calc(1/1000000)', '0.00001') |
Collaborator
There was a problem hiding this comment.
Why does dividing 1 by one million give 1e-06 instead of 1e-05? I guess it's related to the precision being 5 decimal digits, but I would appreciate some explanation or a link to the spec.
| } | ||
| const m = Math.pow(10, prec); | ||
| return Math.round(v * m) / m; | ||
| const rounded = Math.round(v * m) / m; |
Collaborator
There was a problem hiding this comment.
Should be some comment about explaining why the code is doing this or nobody will understand it in the future.
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.
No description provided.