0

HI i am seeing a weird behavior of "-" operator in javaScript for the following equation

 currVal = currVal-1;

here for the value of currVal =2.3 the equation is giving result as 1.2999999999999998 & similarly for 1.4 its giving 0.3999999999999999

Amulya
  • 182
  • 1
  • 12
  • @demongolem is right. That question has the answer to your question. You should use `number.toFixed(x)`, where x is the desired amount of decimal points. – Wold Apr 23 '14 at 03:27
  • Ya he is right but i was doing a decrement operation which needs to show the exact figures if possible so toFixed() i am considering as a last option . How ever i saw currVal = currVal+1; does not give any problem – Amulya Apr 23 '14 at 04:34

0 Answers0