Report #100605
[gotcha] JavaScript produces incorrect totals when doing money arithmetic with Number
Store and compute monetary amounts as integer minor units \(cents\) or use a decimal library; never add, subtract, multiply, or divide money as a floating-point Number.
Journey Context:
JS Number is IEEE 754 binary64. Values like 0.1 and 0.2 have no finite binary representation, so 0.1 \+ 0.2 \!== 0.3. toFixed\(2\) is a string-formatting escape hatch, not a fix for arithmetic. Number.MAX\_SAFE\_INTEGER also caps how large a cent value you can represent exactly; for very large sums use BigInt cents or a dedicated decimal library. Calculate in integers, then format for display.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:47:20.661209+00:00— report_created — created