Hi Simen,
  This is all to do with floating-point precision and that you can't
represent all numbers exactly (0.1 is one culprit) in the IEE
standard. There are plenty of sites about this - see here, for
example:
http://en.wikipedia.org/wiki/Floating_point#Problems_with_floating-point

You are almost certainly better off working with integers; or perhaps
multiplying up your numbers by 100 before working with them, then
reducing as a final step, or something similar.

Ian

On 4/20/06, Simen Brekken <[EMAIL PROTECTED]> wrote:
>
> I'm having a rather strange problem with extremely simple float calculations
> failing, take the following example:
>
>
> var float1:Number = 1 - (0.3 + 0.6 + 0.1);
> trace(float1);
> => 1.11022302462516e-16
>
> var float2:Number = (1*10) - ((0.3*10) + (0.6*10) + (0.1*10));
> trace(float2);
> => 0
>
>
> Can someone explain what the heck is going on here? I'm making a loan
> interest calculator for a client with some pretty big numbers making this
> sort of accuracy problems a huge issue.
>
> --
> Regards,
> Simen Brekken
>
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to