2
alert(413284921265094656 + "");

but it prints 413284921265094660, even if I "convert" it in string.

markzzz
  • 47,390
  • 120
  • 299
  • 507

1 Answers1

1

Perhaps I don't understand the question, but...

alert("413284921265094656")

The interpreter is trying to store 413284921265094656 as a double-precision floating point number, but the number exceeds the precision limit, so the least significant bits are being lost. You can't store a number with that much precision (roughly speaking, that many digits or "significant figures") in JavaScript without use of a big-int library.

TypeIA
  • 16,916
  • 1
  • 38
  • 52