Report #12791
[gotcha] Integer representation exceeds Number.MAX\_SAFE\_INTEGER \(2^53-1\) in high-precision financial calculations
Use BigInt for whole numbers exceeding 9 quadrillion, or decimal libraries \(decimal.js, dinero.js\) for fractional calculations. Never use Number for crypto satoshis or aggregated high-frequency trading values.
Journey Context:
Developers convert monetary values to integers \(cents\) to avoid floating point errors, assuming JavaScript integers are arbitrary precision. However, IEEE 754 double-precision floats \(which JS Numbers are\) only reliably represent integers up to 2^53-1 \(9,007,199,254,740,991\). In cryptocurrency \(satoshis\), forex \(pips\), or aggregated market data, values frequently exceed this limit, causing silent precision loss \(e.g., 9,007,199,254,740,993 becomes 9,007,199,254,740,992\). BigInt solves this for whole numbers but cannot mix with Number; decimal libraries handle arbitrary precision arithmetic correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:54:06.383092+00:00— report_created — created