0

Possible Duplicate:
Is JavaScript’s Math broken?
Javascript rounding issue

What is the Floating value behavior in java script? How the default precision value behavior?

I was wandering when, I checked

0.1 + 0.2 in console it give me 0.30000000000000004

Can anyone please help me to understand why this happened and its behavior.

Thanks in Advance.

Community
  • 1
  • 1
Soarabh
  • 2,910
  • 9
  • 39
  • 57
  • 1
    This is standard floating point rounding issues, which has been asked here countless times. Take a look at [this post](http://stackoverflow.com/questions/4041816/javascript-rounding-issue) for instance. – Ted Hopp Oct 25 '12 at 06:53
  • You need to use Round function and for more info go to http://stackoverflow.com/questions/1458633/elegant-workaround-for-javascript-floating-point-number-problem – Umair Aziz Oct 25 '12 at 07:13
  • http://www.mredkj.com/javascript/nfbasic2.html – Umair Aziz Oct 25 '12 at 07:15
  • If you only interested to know reason Why it cannot be done then "Actually, the error is because there is no way to map 0.1 to a finite binary floating point number." – Umair Aziz Oct 25 '12 at 07:18

0 Answers0