0

Odd issue:

I enter a very large number into the console, for instance 883036583895237057 and it returns 883036583895237100, just 43 more.

What's happening?

enter image description here

Lev
  • 1,698
  • 3
  • 18
  • 26
  • Because at that scale, that's the number an IEEE-754 double-precision floating point value can hold that's nearest to the number you entered. The highest number that you can add 1 to and get he next integer up is 9007199254740991 (unsurprisingly, 9007199254740991 + 1 = 9007199254740992); after that, adding just 1 won't get you to the next integer (9007199254740992 + 1 = 9007199254740992!). – T.J. Crowder Sep 28 '16 at 17:47
  • 5
    http://stackoverflow.com/questions/1379934/large-numbers-erroneously-rounded-in-javascript is a better dupe target. – Sebastian Simon Sep 28 '16 at 17:47
  • Related: http://stackoverflow.com/questions/588004/is-floating-point-math-broken – T.J. Crowder Sep 28 '16 at 17:48
  • I don’t have the gold badge for JS, unfortunately… – Sebastian Simon Sep 28 '16 at 17:49

0 Answers0