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

The problem with numbers with decimals #150

Open
svrostislav opened this issue May 8, 2020 · 2 comments
Open

The problem with numbers with decimals #150

svrostislav opened this issue May 8, 2020 · 2 comments

Comments

@svrostislav
Copy link

If I pass min equals to 1, max equals to 1.8 and step equals to 0.1 I get value 1.7000000000000002 on change

@ckainz11
Copy link

I couldn't fix the problem either, however I have a workaround that you can use. In your onChange function round the value to one decimal point: let roundedValue = Math.round(value * 10) / 10. Also, if you are using the tooltip, there will probably also be this issue where it shows, for example: 1.30000. This can be fixed by using the following format function:
const format = value => Math.round(value * 10) / 10 and then passing that to the Slider component

@svrostislav
Copy link
Author

@ckainz11 thank you
I had resolved this issue on our project exactly in this way.

Maybe someone may resolve it under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants