Dev & Computing · 大数(BigInt 与精度上限) · Updated 2026-10-25
What Is BigInt & Numeric Precision?
Definition
JavaScript numbers are 64-bit doubles: 1 sign + 11 exponent + 52 mantissa bits, so integers above 2^53−1 lose precision. Order IDs and 64-bit snowflake IDs round-trip corrupted: an id of 1234567890123456789 arrives as …790 after JSON.parse. Three fixes: BigInt literals (9007199254740993n), serialize IDs as strings, or split fields. Money is the same story: 0.1+0.2 ≠ 0.3 in binary — always store cents as integers or use a decimal library.
Formula
Number.MAX_SAFE_INTEGER = 2^53 − 1 = 9,007,199,254,740,991
Worked Example
JSON.parse('{"id":9007199254740993}').id → 9007199254740992 (last digit eaten); as a string "9007199254740993" it survives intact.
Common Misconception
"More decimal places fix the float error" — the root is binary representation; no digit count cures 0.1+0.2−0.3 = 5.5e-17. Use integer cents or a decimal library. And BigInt never mixes with Number in arithmetic — explicit conversion or TypeError.
Matching Calculators
Related Terms
Keep Exploring
Browse the full glossary, or head back to the homepage for 1,435 free online calculators.
Back to glossary