Number Precision & BigInt Playground

Integers above 2^53 as a Number: are all their digits still there? BigInt (123n) holds them exactly, however big. Then try mixing one with a Number, or…

Why it matters

Ids from an API (Discord, Twitter, a database) are often 18 to 19 digits. Parsed as a Number, their last digits break silently and two different users can "become the same": a bug that is very hard to trace. Know the 2^53 limit and BigInt’s rules, and your big integers stay right.

The key idea

A Number is accurate up to 2^53; above it, use BigInt

Common mistakes

Try it in this playground