When you're checking to see if one Number equals another Number, its common practice to use a range, instead of a strict equals.
Using the results you found, the following would print "WTF"
ActionScript Code:
var n1:Number = 0.6;
var n2:Number = 6 * 0.1;
if (n1 == n2) {
trace ("floating point numbers play nicely");
} else {
trace ("WTF");
}
A common solution is to do something like this:
ActionScript Code:
const EPSILLON:Number = 0.000001;
var n1:Number = 0.6;
var n2:Number = 6 * 0.1;
if ( Math.abs(n1-n2) > EPSILLON) {
trace ("floating point numbers play nicely");
} else {
trace ("WTF");
}
In this case, the first statement is printed. Youre basically saying "If n1 is equal to, or reaaaaaally close to n2..."