Groups | Blog | Home
all groups > flash actionscript > january 2006 >

flash actionscript : Strangest bug with numbers!?!?


NSurveyor
1/24/2006 10:49:23 PM
Hmmm... I put the following code on Frame 1 of a blank document:

x = 4.31*100;
trace('x : '+x);
trace('floor(x) : '+Math.floor(x));
trace('ceil(x) : '+Math.ceil(x));
trace('round(x) : '+Math.round(x));
trace(x+' == '+Math.round(x)+' ? '+(x == Math.round(x)));

After running it, this is what is outputted:

x : 431
floor(x) : 430
ceil(x) : 431
round(x) : 431
431 == 431 ? false

What's going on? It's as though the number is actually between 430.5 and 431
but it shows 431 when traced.

How come this is happening? Maybe something is just wrong with my flash? By
the way, it only happens with 4.31, but maybe there are other numbers...
kglad
1/25/2006 3:03:24 AM
NSurveyor
1/25/2006 3:24:32 AM
Ah, I remember you addressed this problem once before...

AddThis Social Bookmark Button