0

I met a very weird situation in JavaScript, which is that

9007199254740992 + 1 = 9007199254740992
9007199254740992 + 3 = 9007199254740996

Does anyone know the reason for this? Thanks a lot in advance!

Yizhe
  • 95
  • 1
  • 6
  • 1
    Nothing weird about it, commonly known limitation of 64bit floating point ... see `Number.MAX_SAFE_INTEGER` == `9007199254740991` - any integer maths above that value (or below the negative of that) is not going to be accurate at all - by the way, that number is 2^53 - 1 – Jaromanda X Jun 02 '17 at 03:27
  • @JaromandaX I see. Thanks so much! – Yizhe Jun 02 '17 at 03:30

0 Answers0