1 Reply Latest reply on Oct 26, 2011 4:30 PM by kraikit

    Flash Builder Rounding Inconsistencies

    F.Bowman Level 2

      I'm working on a piece of software in Flash Builder that has to perform calculations at some point and I've noticed the following:-


      If I calculate the following I end up with these results:


      0.045 * 4333 = 194.98499999999999

      0.035 * 4333 = 151.655


      Why does the first calculation provide a result with so many decimal places? Is there any way to modify this behaviour? Note that if I perform the first calculation on a regular calculator, the result is 194.985.


      If I calculate the following with the following decimal place modification, I end up with the following:


      (0.045 * 4333).toFixed(2) = 194.98

      (0.035 * 4333).toFixed(2) = 151.66


      The first calculation ends up being incorrect as it's off by 0.01.


      Is there any explanation for the behaviour of the first calculation?