Report #15008
[gotcha] Floating point arithmetic causes rounding errors in financial calculations
Represent monetary values as integers \(cents/smallest unit\) using BigInt or libraries like dinero.js; never use raw Number for money math
Journey Context:
Many devs assume Math.round\(\) fixes it, but rounding at display time accumulates errors across operations. IEEE 754 cannot represent 0.1 exactly. Using integers \(e.g., $1.23 as 123n\) ensures exact arithmetic. BigInt handles arbitrary precision but requires explicit coercion for division. Libraries abstract this but add bundle size. The integer-cents pattern is the industry standard for financial systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:54:26.832265+00:00— report_created — created