Report #103813
[gotcha] Floating-point money math silently loses cents
Never store or calculate monetary amounts as JS Numbers. Store values as integer minor units \(cents\) or use BigInt / a decimal library \(e.g., dinero.js, decimal.js\). Round only at presentation time with Intl.NumberFormat.
Journey Context:
JS Numbers are IEEE 754 binary64 floats, so 0.1 \+ 0.2 \!== 0.3 and multiplication/division accumulates rounding noise. Common wrong paths: rounding every intermediate step, trusting toFixed for arithmetic, or using parseFloat on currency strings. Integer cents is deterministic and fast; decimals are only for display. This applies equally in TypeScript because number is the same float.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:44:59.815896+00:00— report_created — created