Make a new AS3 Document in Flash, paste in the following code and run it:
var a:Number=0;
trace(a) // 0
a+=0.3;
trace(a) // 0.3
a+=0.3;
trace(a) // 0.6
a+=0.3;
trace(a) // 0.8999999999999999
a+=0.3;
trace(a) // 1.2
a+=0.3;
trace(a) // 1.5
a+=0.3;
trace(a) // 1.8
a+=0.3;
trace(a) // 2.1
a+=0.3;
// ^ This is the output. Notice the inaccuracy starting from 0.9 / 0.89
Why the error? I'm just doing an ordinary hi resolution addition.
Any workarounds?