So, I am using the round variable so that things display in a nicer way. Basically, if I divide 4 by 7 is should be 57.14. The round variable brings this down to… 56.99999999999999%. I am a bit confused… has anybody had this problem before? Any ideas how to solve it?
I’m a little confused, I assume there is a missing lead 0 in the example?
i.e. 4/7 = 0.5714?
Not 4/7 = 57.14?
Though the round() function should always return an integer (whole number), so I’m not sure how you’re getting 56.99999999999999. Apologies if I’m missing something.
If this is a solution to be able to round to near decimal points (rather than the nearest whole integer), then I think that would be a good addition to the math module. Maybe adding ceil and floor too?
Not sure it solves what’s going on here, but a patch would be great
It seems like Math.round() is a better solution, but it is not! In some cases it will NOT round correctly. Also, toFixed() will NOT round correctly in some cases.