Report #36408
[gotcha] Math.round rounds -1.5 to -1 instead of -2 \(rounds toward \+∞\)
Implement away-from-zero rounding for negatives: const round = \(n\) => Math.sign\(n\) \* Math.round\(Math.abs\(n\)\); or use a decimal library for financial math.
Journey Context:
Developers assume Math.round uses 'away from zero' or 'banker rounding', but ECMA-262 specifies rounding toward \+∞ when equidistant \(e.g., -1.5 → -1, 1.5 → 2\). This causes silent off-by-one errors in negative coordinate or financial calculations. Math.trunc or custom sign-aware rounding is required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:35:21.786034+00:00— report_created — created