I hope theres a javascript expert that can help. I am trying to round numbers to 2 decimal places example
3.342 = 3.34
4.565 = 4.57
means from the third digit is 5 and above to round to the next decimal, and with no change below 5 I have something like
var num = Math.round(n*100)/100
and it works for other numbers but not for n = 4.225 which rounded would be 4.23 and because I couldn't find the issue I printed n*100 this is 4.225*100 and it turns I got 422.49999999999994 instead of 422.5 and that explains why Math.round gives me 4.22 instead of 4.23.
please, can anybody give some light on this issue?
This is happening with other numbers too and I have no solution yet. I also added math.Epsilon like
(n+math.Epsion) * 100