N
niko.nyman
I noticed weird results when using eval() to do some simple
calculations. Here are a few eval() statements and the corresponding
results from JavaScript:
eval("1.2+0.97") => 2.17
eval("1.2+0.98") => 2.1799999999999997
eval("1.2+0.99") => 2.19
eval("1.2+0.981") => 2.181
This can happen with other numbers as well, but certainly not with any
combination.
I have confirmed this on Firefox and Safari, two different versions of
OS X and both Intel and PowerPC Macs.
calculations. Here are a few eval() statements and the corresponding
results from JavaScript:
eval("1.2+0.97") => 2.17
eval("1.2+0.98") => 2.1799999999999997
eval("1.2+0.99") => 2.19
eval("1.2+0.981") => 2.181
This can happen with other numbers as well, but certainly not with any
combination.
I have confirmed this on Firefox and Safari, two different versions of
OS X and both Intel and PowerPC Macs.