Report #102460
[gotcha] JavaScript Number produces rounding errors in monetary calculations \(e.g. 0.1 \+ 0.2 \!== 0.3\)
Store money as integer minor units \(cents\) or use BigInt / a decimal library; never use binary floating point for money.
Journey Context:
JavaScript numbers are IEEE 754 binary64, which cannot exactly represent most decimal fractions. Tricks like toFixed\(\) only round at format time and still carry error through intermediate operations. Integer minor units are exact, fast, and serialization-friendly. BigInt is useful for very large values. Decimal libraries trade performance for arbitrary-precision decimal math.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:55:00.120037+00:00— report_created — created