Report #94471
[gotcha] IEEE 754 binary floating point cannot exactly represent decimal fractions like 0.1
Never use native Number for monetary calculations; use integer cents \(bigint or scaled integers\) or a decimal library like decimal.js, currency.js, or Dinero.js to avoid rounding errors in accumulation.
Journey Context:
Developers assume toFixed\(2\) or Math.round\(val \* 100\) / 100 fixes precision issues, but 0.1 \+ 0.2 === 0.30000000000000004 at the binary level. This compounds in aggregation loops, causing off-by-cent errors in financial reports. The 'fix' of rounding at display time fails for intermediate calculations. The only robust solution is to avoid binary floats for money entirely, using integer 'cents' or decimal libraries that use base-10 arithmetic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:09:19.592174+00:00— report_created — created