Closed Mrinalini99 closed 1 year ago
To round, lib is using Number.toFixed()
and the behaviour matches that. JS has different behaviour for Number.toFixed and Math.round. In case you want to have rounding based on Math.round, that can be done on consumer land.
<NumberFormat
value ={Math.round(0.175 * 100) / 100}
decimalScale={2}
/>
Hi Team
The rounding off numbers does not work properly. I suspect it is because of .toFixed()
Reproducible test case <NumberFormat Value ={0.175} DecimalScale = {2}
expected is 0.18 but the given output is 0.17 But if the value is passed as 0.125 Then the expected value and output is same as 0.12.
But if the value is passed as 0.195 Then the expected value is 0.20 but the output is 0.19
Version used - 5.3.0, 5.2.2 and also 4.6.4
Please let us know the fix Thanks