Division inaccurate in Javascript?
- by Nate
If I perform the following operation in Javascript:
0.06120*400
The result is 24.48.
However, if I do this:
24.48/400
The result is:
0.061200000000000004
JSFiddle: http://jsfiddle.net/zcDH7/
So it appears that Javascript rounds things differently when doing division and multiplication?
Using my calculator, the operation 24.48/400 results in the correct answer of 0.0612.
How should I deal with Javascript's inaccurate division? I can't simply round the number off, because I will be dealing with numbers of varying precision.
Thanks for your advice.