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

Rounding with decimalScale={1} #820

Open
cwagner22 opened this issue Jan 17, 2024 · 1 comment
Open

Rounding with decimalScale={1} #820

cwagner22 opened this issue Jan 17, 2024 · 1 comment

Comments

@cwagner22
Copy link

cwagner22 commented Jan 17, 2024

<NumericFormat value={51.97} decimalScale={1} />
renders 52.0 which is wrong in my opinion, it should be 52, without decimals.

https://codesandbox.io/p/sandbox/decimalscale-demo-forked-7zky75

Related to maximumFractionDigits mentioned in #752

@s-yadav
Copy link
Owner

s-yadav commented Feb 25, 2024

Yes, that makes sense, as that would be closer to Intl.NumberFormat. But as it is a behaviour change, the best time to handle this will be with maximumFractionDigits, and minimumFractionDigits.

Meanwhile workaround is to handle it parent level by using Intl.NumberFormat.

<NumericFormat value={Intl.NumberFormat('en', {maximumFractionDigits: 1})} valueIsNumericString decimalScale={1} />

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