Subtraction Problem in Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasadmoyarath
    New Member
    • Oct 2006
    • 2

    Subtraction Problem in Javascript

    If i subtract .01 from 100000000000000 like 100000000000000 - Math.pow(10,(-1 * 2)), i am getting 99999999999999. 98. If i cut one zero from the number, result is correct and if i add one more zero to the number, subtraction won't happen.Can somebody help to solve it?
  • prasadmoyarath
    New Member
    • Oct 2006
    • 2

    #2
    Subtraction Problem in Javascript

    In Javascript if i subtract .01 from 100000000000000 like 100000000000000 - Math.pow(10,(-1 * 2)), i am getting 99999999999999. 98. If i cut one zero from the number, result is correct and if i add one more zero to the number, subtraction won't happen.Can somebody help to solve it?

    Comment

    • ajk99
      New Member
      • Apr 2007
      • 1

      #3
      Originally posted by prasadmoyarath
      In Javascript if i subtract .01 from 100000000000000 like 100000000000000 - Math.pow(10,(-1 * 2)), i am getting 99999999999999. 98. If i cut one zero from the number, result is correct and if i add one more zero to the number, subtraction won't happen.Can somebody help to solve it?
      Did you find an answer? I was surprised to discovered that 250 - 39.92 = 210.07999999999 998 in both IE and Firefox.
      Rgrds

      Comment

      Working...