Grokking Advanced JavaScript
Vote

0% completed

​

BigInt

Type console.log(9007199254740993) into Node, and it prints 9007199254740992. The program did not make an arithmetic mistake. The ordinary number type simply cannot store that integer, so it stored the nearest value it could hold.

Why Ordinary Numbers Lose Whole Numbers

A JavaScript Number is a 64-bit floating-point value. It stores every whole number exactly up to 2<sup>53</sup> - 1, which is 9,007,199,254,740,991 and is available as Number.MAX_SAFE_INTEGER. Above that limit, the values a Number can hold are 2 or more apart, so some integers have no exact representation.

``

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content