1
I hold the following value: 6.175
When I use the .toFixed(2)
that number the correct value that should be returned is 6.18
, right?
But I’m getting 6.17
as a return. There is another way to carry out this rounding so that it is done correctly?
Check this out: https://answall.com/q/207612/5878
– Woss
@Andersoncarloswoss but from what is said one of the answers the
.toFixed()
should round up, in which case you’re doing the opposite of that– R.Santos
(Math.round(6.175 * 100) / 100). toFixed(2) did not solve for you? (note: I did not test with other values to see how this function behaves)
– Leonardo Bosquett
I also noticed that 6.175 has problems with the IEEE 754 representation, it would be like this in fact: 6.1749999999999999998223643160599749535353893310546875, I think that is why toFixed(2) returns 6.17
– Leonardo Bosquett