0

I was goofing around when I decided to try to show a varaible on the console. this is my JS

test = 8888888888888888888;
console.log(test)

however, on the console, this was shown:

number on console

Why did 8888888888888888888 go to 8888888888888889000?

FlipFloop
  • 1,233
  • 1
  • 14
  • 25

1 Answers1

3

The number is larger than the largest value that can be represented exactly in a double-precision floating point value. Modern runtimes expose a constant on the Number constructor with the maximum value (Number.MAX_SAFE_INTEGER). The value is 9007199254740991.

Pointy
  • 405,095
  • 59
  • 585
  • 614