AS3's Number type, like Java's or C++'s 'double' type, store floating-point values using binary fractions, not decimal fractions, so there is some loss of precision occuring. There is no fractional-decimal type in AS3.
I'll leave it to folks in the developer community working on financial applications to explain how they work around this limitation. Gordon Smith Adobe Flex SDK Team ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Vadim Melnik Sent: Monday, July 14, 2008 9:17 AM To: [email protected] Subject: [flexcoders] Float number calculation in AS3 Hello All, Its should be very simple, I saw posts related to this issue before in this list, but somehow was unable to find it right now. Below is listed simple test case for problem: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " creationComplete="test()"> <mx:Script><![CDATA[ private function add(v1:*, v2:*, v0:*):* { var v3:* = v1+v2; var status:String = (v0==v3)?"OK":"failure"; trace("("+v1+") + ("+v2+") = "+v3+", "+status); return v3; } private function test():void { add(1.2, 1, 2.2); add(1.2, -1, 0.2); add(82003.9, -16923, 65080.9); add(3.2, -1, 2.2); } ]]></mx:Script> </mx:Application> And result output: (1.2) + (1) = 2.2, OK (1.2) + (-1) = 0.19999999999999996, failure (82003.9) + (-16923) = 65080.899999999994, failure (3.2) + (-1) = 2.2, OK Is it bug or special behavior in AS3 by design, that second and third "add" calls produces strange results instead of 0.2 and 65080.9. In other words it's impossible to compare two calculated financial values on Flex side . -- Thanks, Vadim.

