Well I’m having a little problem with decimal in as3. Here’s what I’m trying to do :
[AS]
var p:Number = 0;
addEventListener(Event.ENTER_FRAME, mainLoop);
function mainLoop(evt:Event){
p+= 0.1;
trace§;
}
[/AS]
And I get those weird results :
0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
1.0999999999999999
In AS2, no problem, I get the right incrementation. Also, doing this in AS3 works well too:
[AS]
var p:Number = 0;
addEventListener(Event.ENTER_FRAME, mainLoop);
function mainLoop(evt:Event){
p+= 1;
trace(p/100);
}
[/AS]
Any idea why this is happening?