re: Explain BigInt Like I'm Five VIEW POST

FULL DISCUSSION
 

Javascript remembers numbers in a clever way (called 'double-precision floating point') that allows programmers to use really big numbers, really small numbers, numbers that have decimal points in them and numbers that don't all the same way, and mix them together without worrying which is which.

The problem is that there just isn't enough room for Javascript to store every possible number this way. There are lots of numbers Javascript just doesn't know about, and when you tell it to try, it just goes with whatever is the closest number it does know.

For most numbers this is OK, but for numbers you don't use very often (like really big ones), it can cause problems. For example, Javascript thinks that "9,007,199,254,740,992 + 1" still equals 9,007,199,254,740,992

This might seem like a REALLY BIG NUMBER that you're never going to use (and I'm sure the original Javascript engineers thought so too), but it turns out that programmers use really big numbers all the time, and changing them to a different number without the programmer knowing can cause all sorts of things to go wrong.

BigInt is a way to tell Javascript that you want to make sure your really big (or really small) numbers are remembered properly. You can't use decimal points any more, but at least your sums add up.

code of conduct - report abuse