Report #99662
[gotcha] 0.1 \+ 0.2 \!== 0.3 and other floating-point money math surprises
Store monetary amounts as integer smallest-currency units \(cents\). For division or arbitrary precision, use a decimal library. Never use === to compare the result of float arithmetic.
Journey Context:
IEEE 754 binary floating point cannot exactly represent decimal fractions like 0.1. This is not a JS bug, but it is a JS footgun because Number is the only numeric primitive and JSON has no native decimal type. The classic wrong fix is to round at display time while still passing floats through business logic, which accumulates rounding errors across tax, discount, and split-payment calculations. The robust pattern is integer cents everywhere except final formatting, which also makes amounts naturally JSON-safe and database-friendly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:50:55.451414+00:00— report_created — created