2

I'm currently playing around with large numbers in JavaScript and stumbled across something that I don't quite understand:

From the Mozilla JavaScript Doc I found the following statement:

The MAX_VALUE property has a value of approximately 1.79E+308. Values larger than MAX_VALUE are represented as "Infinity".

Just for fun I hacked some lines in my Google Chrome console to see what would happen if I used a larger number than Number.MAX_VALUE and I was surprised by the result:

Number.MAX_VALUE + 1 === Infinity

returns false.

Number.MAX_VALUE+Math.pow(10,291) === Infinity

returns false.

Number.MAX_VALUE+Math.pow(10,292) === Infinity

returns true.

Just by definition I would already expect the first example to return true. Why is that not the case? What am I missing?

snrlx
  • 4,987
  • 2
  • 27
  • 34

0 Answers0