I don't understand why the values in the following code are not equal to 1:
var a:uint = (4.1-1.7)/2.4;
trace(a);//traces 0
var b:int = (4.1-1.7)/2.4;
trace(b);//traces 0
var c:Number = (4.1-1.7)/2.4;
trace(c);//traces 0.9999999999999998
I don't understand why the values in the following code are not equal to 1:
var a:uint = (4.1-1.7)/2.4;
trace(a);//traces 0
var b:int = (4.1-1.7)/2.4;
trace(b);//traces 0
var c:Number = (4.1-1.7)/2.4;
trace(c);//traces 0.9999999999999998
This is because in most languages real, non-integer numbers are stored using floating point representation (http://en.wikipedia.org/wiki/Floating_point), which is inherently susceptible to minor inaccuracies.