It has to do with the fact that computers have to convert all numbers to binary 
then perform math on those numbers and then convert back to decimal. In the 
process of this conversion you get results like these.

If you need the addition to be accurate and you know that the numbers will 
always be decimals you can multiply the numbers by 100 and then you will add 27 
+ 3 which  will return 30 and then divide it by 100 to get your .3 (or at least 
I think that will work as I have not tried it)

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Adrian Zajac
Sent: Tuesday, December 14, 2010 8:43 AM
To: Flash Coders List
Subject: [Flashcoders] problem with adding two digits

Hello,

First of all, I want to say Hi to everyone here. This is my first post.


Please, take a look at this part of code:

     trace (0.27 + 0.03);   // output --> 0.30000000000000004

Can anyone tell me why I get this weird result in output window?


Regards
Adrian
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to