Skip to content
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

[Slider] Mitigate floating point errors #16252

Conversation

joaosilvalopes
Copy link

When step was a decimal number the calculated value form a value change was coming with floating point errors.

This fixes it by rounding the calculated value to step precision.

Closes #16151

@mui-pr-bot
Copy link

Details of bundle changes.

Comparing: 564aed3...0e3e593

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core 0.00% 0.00% 318,911 318,911 87,557 87,557
@material-ui/core/Paper 0.00% 0.00% 68,281 68,281 20,353 20,353
@material-ui/core/Paper.esm 0.00% 0.00% 61,578 61,578 19,133 19,133
@material-ui/core/Popper 0.00% 0.00% 28,968 28,968 10,411 10,411
@material-ui/core/Textarea 0.00% 0.00% 5,513 5,513 2,374 2,374
@material-ui/core/TrapFocus 0.00% 0.00% 3,755 3,755 1,580 1,580
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,012 16,012 5,791 5,791
@material-ui/core/useMediaQuery 0.00% 0.00% 2,597 2,597 1,102 1,102
@material-ui/lab +0.07% 🔺 +0.09% 🔺 140,480 140,574 43,417 43,454
@material-ui/styles 0.00% 0.00% 51,703 51,703 15,337 15,337
@material-ui/system 0.00% 0.00% 15,266 15,266 4,333 4,333
Button 0.00% 0.00% 84,273 84,273 25,630 25,630
Modal 0.00% 0.00% 20,345 20,345 6,689 6,689
Slider +0.13% 🔺 +0.16% 🔺 74,587 74,681 23,184 23,221
colorManipulator 0.00% 0.00% 3,904 3,904 1,544 1,544
docs.landing 0.00% 0.00% 55,232 55,232 13,946 13,946
docs.main 0.00% 0.00% 651,017 651,017 205,042 205,042
packages/material-ui/build/umd/material-ui.production.min.js 0.00% 0.00% 292,168 292,168 83,484 83,484

Generated by 🚫 dangerJS against 0e3e593

@joshwooding joshwooding added component: slider This is the name of the generic UI component, not the React module! new feature New feature or request labels Jun 15, 2019
@oliviertassinari
Copy link
Member

@joaosilvalopes Well done.

@joaosilvalopes joaosilvalopes deleted the Slider/mitigate-floating-point-errors branch June 17, 2019 17:20
@alitaheri
Copy link
Member

This has broken the Slider where the precision of step is small (0.00000001) since it converts to 1e-8 not 0.00000001.

@eps1lon
Copy link
Member

eps1lon commented Jun 27, 2019

This has broken the Slider where the precision of step is small (0.00000001) since it converts to 1e-8 not 0.00000001.

Those are the same numbers just represented differently (1e-8 is scientific notation).

@oliviertassinari
Copy link
Member

@alitaheri Do you have an idea on how we can solve this problem?

@alitaheri
Copy link
Member

alitaheri commented Jun 27, 2019

@oliviertassinari I already have. making a PR.

@oliviertassinari
Copy link
Member

🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slider stepValue < 1 gives rounding errors
6 participants