# AS3 Decimal Precision

**URL:** <https://forum.kirupa.com/t/as3-decimal-precision/213360>\
**Category:** flash\
**Created:** [January 18, 2007, 10:54pm UTC](https://forum.kirupa.com/t/as3-decimal-precision/213360 "2007-01-18T22:54:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tecknoize](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tecknoize](https://forum.kirupa.com/u/tecknoize)\
**Post date:** [January 18, 2007, 10:54pm UTC](https://forum.kirupa.com/t/as3-decimal-precision/213360/1 "2007-01-18T22:54:53Z")

</div>

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?
