0

In Chrome developer tools, manipulating values like code below:

var total=0;
total+=32;
total+=11.2;
total+=3.2;

the result I am getting is:

46.400000000000006

i am confused, why is the 6 added at the end?

enter image description here

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Santhosh
  • 7
  • 2
  • 1
    Possible duplicate of [Getting weird value in Double](https://stackoverflow.com/questions/32747174/getting-weird-value-in-double) – Alexandre Beaudet Jul 02 '18 at 07:03
  • 4
    Possible duplicate of [Is floating point math broken?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – jonrsharpe Jul 02 '18 at 07:03
  • @AlexandreBeaudet the canonical dupe has over 2,000 linked questions, that seems more than enough signposts. And generally: people's votes are their own, don't tell them what to do. – jonrsharpe Jul 02 '18 at 07:08
  • @jonrsharpe "Generally, people's votes are their own", can agree with this, but also agree with the general feeling on the blog/meta that stack isn't welcoming for newer users, just downvoting because he didn't find the info by himself contribute to that – Alexandre Beaudet Jul 02 '18 at 09:25

0 Answers0