Report #61602
[gotcha] JavaScript integer precision loss above Number.MAX\_SAFE\_INTEGER causes silent equality failures
Validate integers with Number.isSafeInteger\(\) before comparison; use BigInt for IDs or values exceeding 2^53-1, serializing to string for JSON transport
Journey Context:
IEEE 754 double-precision floats only reliably represent integers up to 2^53. Beyond this, the unit in the last place \(ULP\) exceeds 1, causing adjacent integers to map to the same float representation. This leads to silent data corruption when parsing large IDs \(e.g., Twitter snowflake IDs\) as Numbers instead of strings or BigInts. The common mistake is assuming === will catch overflow; it won't because both sides round to the same value. BigInt is the correct type, but note that mixing BigInt with Number in arithmetic throws TypeError, requiring explicit conversion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:53:10.041650+00:00— report_created — created