-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(number-field, slider): floating point roundoff precision bug #4263
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
3f6fde4
fix(number-field): fixed precision bug
blunteshwar c8a49bc
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar 15bf141
chore(number-field): some minor fix
blunteshwar 85bcd8e
chore(slider, number-field): added some tests and story
blunteshwar 87f073b
Apply suggestions from code review
blunteshwar 763c8d1
Revert "Apply suggestions from code review"
blunteshwar 831ebbb
chore(number-field): updated test name
blunteshwar 5f4fc2e
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar dd6ee09
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar c0675ae
fix(number-field): number formatter to format decimal values
blunteshwar 5b080da
Merge branch 'blunteshwar/slider-not-rounding-values' of github.com:a…
blunteshwar 3d5f8af
chore(number-field): minor fix
blunteshwar 81f20ca
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar 947091b
chore(number-field): implemented formatter using getter
blunteshwar 53e621a
Merge branch 'blunteshwar/slider-not-rounding-values' of github.com:a…
blunteshwar 8b52e92
chore(number-field): implemented single number formatter
blunteshwar 88a4a4d
chore(number-field): some minor fix
blunteshwar 8ce6361
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar a21b404
chore(number-field): minor fixes
blunteshwar e077c20
Merge branch 'blunteshwar/slider-not-rounding-values' of github.com:a…
blunteshwar d0b8d53
chore(number-field): implemented an independent formatter
blunteshwar 70b6b14
chore(number-field): minor change
blunteshwar 395e004
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar 14cbe9e
chore(number-field): cached digitsAfterDecimal
blunteshwar d4affc5
Merge branch 'blunteshwar/slider-not-rounding-values' of github.com:a…
blunteshwar 207ec62
chore(number-field): some minor changes
blunteshwar f5ad973
chore(number-field): minor fix
blunteshwar 05f8bf9
chore(number-field): minor ts fix
blunteshwar c8e2faf
chore(number-field): minor ts check fix
blunteshwar b218046
Merge branch 'main' into blunteshwar/slider-not-rounding-values
blunteshwar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to only format at the end to reduce the chances of fidelity loss?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, We need this
const moduloStep = parseFloat(this.valueFormatter.format((value - min) % this.step));
format because in some casesmoduloStep
is evaluated as 0.00000000000017 or very close to zero , but it should be evaluated to 0, hence this formatting is required.And we need this
value = parseFloat(this.valueFormatter.format(value));
because after modulostep is evaluated the value ofstep
is added tovalue
and hence we again have to finally format it.Basically the first format is to correctly calculate the moduloStep and the second format is to correctly calculate the
value
upto required decimal places in accordance withstep
.