i think it's not the bug of AS3 or Flex but processor, and this quite
fundamental so this is "a feature" not "a bug" :)
use rounding to arbitrary precision (it's what other languages do)
and for finance calculations it's better to use integers and modular
arithmetic, i guess

--- In [email protected], "Vadim Melnik" <[EMAIL PROTECTED]> wrote:
>
> 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";
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.
>


Reply via email to