No, you're not doing anything wrong. It's just a fact of life that
computers use binary and we humans use decimal. You will get a
rounding error when converting between the two radix's. There are a
number of posts on the net explaining this better than me:

http://e2easy.wordpress.com/2008/09/25/overcoming-rounding-errors/
http://joshblog.net/2007/01/30/flash-floating-point-number-errors/
http://www.kirupa.com/forum/showthread.php?t=247416



--- In [email protected], "Ken Johnson" <kenjohnso...@...> wrote:
>
> Hi Everyone -
> 
> Given the following code:
>       var num1:Number = 0.72;
>       var num2:Number = 0.198;
>       var num3:Number;
>                       
>       num3 = num1;
>       num3 += num2;
> 
> I would expect num3 to equal 0.918.
> 
> Instead, it equals 0.9179999999999999.
> 
> And when I apply a number formatter with a precision of 2, I get 0.91.
> 
> I am performing financial calculations, and this is not acceptable.
> 
> Am I doing something wrong here?
> 
> Thanks for your help!
> Ken
>


Reply via email to