1 Reply Latest reply on Sep 16, 2008 2:48 AM by Newsgroup_User

    Why 0.3-0.3 != 0

    heart_kub

      Why 0.3-0.3 != 0
        • 1. Re: Why 0.3-0.3 != 0
          Level 7
          Must be a problem with float precision. You could use Math.abs to check
          if the difference is lower than the smallest value you need.

          if (Math.abs(total-0.3)<0.00001) ...

          Or you could round the value ..


          var total:Number = 0.8;

          total -= 0.5;

          total = Math.round(1000*total)/1000

          trace("WHY WHY WHY Current total is>"+total);
          trace("WHY "+total+"-0.3 = "+(total-0.3));

          Then it will bekome = 0