Report #101030
[gotcha] 0.1 \+ 0.2 \!== 0.3 and other decimal money math errors in JavaScript
Store monetary amounts as integer minor units \(cents\) or use a decimal library such as decimal.js; never use raw Number arithmetic for money.
Journey Context:
JavaScript Numbers are IEEE 754 doubles, which cannot exactly represent most decimal fractions. Rounding with toFixed before math is a common band-aid that still fails on intermediate values or comparisons. Integer cents avoids representation error entirely; decimal libraries keep arbitrary-precision decimal arithmetic at the cost of a dependency. This is the standard practice in finance because Number.toFixed/parseFloat round-trips can reintroduce errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:51:48.411288+00:00— report_created — created