5 Replies Latest reply on Oct 20, 2009 7:57 PM by oldMster

    AS3 counting error !?

    BraveTimeMicke

      Why does AS3 count so strange?

       

      var num1:Number = 3.3 - 3; // Should be 0.3 but AS3 make it 0.2999999999999998

       

      var num2:Number = 0.58 * 100;// Should be 58 but AS3 make it  57.99999999999999

       

      My solution:

      var num1:Number = 3.3 -3; // num1 = 0.2999999999999998
      num1= Number(num1.toFixed(2)); // now num1 = 0.3
                 
      var num2:Number = 0.58 * 100;  // num2 = 57.99999999999999
      num2= Math.round(min2); // now num2 = 58

       

      Big bug in AS3?

      Any one else who noticed this?