DEV Community

Discussion on: Explain BigInt Like I'm Five

Collapse
 
preciselyalyss profile image
Alyss 💜

After a bit of searching, I found a pretty good explanation

Large integer IDs and high-accuracy timestamps cannot safely be represented as Numbers in JavaScript. This often leads to real-world bugs, and causes JavaScript developers to represent them as strings instead. With BigInt, this data can now be represented as numeric values.

For an ELI5 version, numbers in javascript are like a sandbox. If you pour in too much sand, it overflows the sandbox. If everyone in the world wanted to trade pokemon at the same time, it would be hard for the computer to keep track of which pokemon should go to the right person. It would be keeping tracking of billions of trades occurring all at once. With better time stamps and higher number counts, you can successfully trade billions of pokemon.

Collapse
 
andrewlucker profile image
Andrew Lucker

normal 64 bit int is between -9223372036854775807 and 9223372036854775807. Larger values wrap around or explode etc.

64 bit float is same size but has "gaps" between larger numbers.

BigInt just starts taking up more memory, but otherwise can represent large integers without any loss of information.