Report #70376
[gotcha] 0.1 \+ 0.2 \!== 0.3 and money calculations silently drift
Store and compute money in integer minor units \(cents\) or use a decimal arithmetic library like decimal.js; never rely on raw Number for financial math.
Journey Context:
JavaScript Numbers are IEEE-754 double-precision floats. Decimals such as 0.1 and 0.2 have no exact binary representation, so every operation can introduce a rounding residual that compounds across addition, subtraction, multiplication, and division. Formatting with toFixed\(2\) only hides the problem at display time; intermediate values already carry error. Integer cents gives exact addition and subtraction until you explicitly divide, which forces you to decide on rounding rules. Decimal libraries model the domain explicitly and are the right choice when taxes, interest, or fractional quantities are involved.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:42:15.320794+00:00— report_created — created