Report #50864
[gotcha] Math.round fails for money calculations due to floating point binary representation errors
Use integer arithmetic \(cents as integers/BigInt\) or dedicated decimal libraries; never use Math.round for monetary rounding
Journey Context:
Binary floating point cannot exactly represent common decimal fractions like 0.1 or 0.345. When calculating money with floats \(e.g., \`Math.round\(0.345 \* 100\) / 100\`\), \`0.345 \* 100\` evaluates to \`34.49999999999999\`, which rounds to \`34\` instead of the expected \`35\`. This causes silent financial errors. The robust solution is to store and calculate money as integer cents \(or BigInt\) to avoid fractional representation entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:51:40.659202+00:00— report_created — created