Report #13518
[gotcha] Number.EPSILON comparison fails for large magnitude numbers
Use relative epsilon comparison: Math.abs\(a - b\) <= Math.max\(1, Math.abs\(a\), Math.abs\(b\)\) \* Number.EPSILON
Journey Context:
Number.EPSILON represents the difference between 1 and the next representable float, making it only valid for comparisons near 1.0. For large numbers like 1e10, the ULP \(unit in last place\) exceeds Number.EPSILON, causing direct comparisons to falsely report equality or miss small but significant differences. The relative epsilon pattern scales tolerance by operand magnitude. Alternatives like exact equality \(===\) fail for accumulated rounding errors, and fixed epsilon values break at different scales. This is critical for financial calculations with large values or scientific computing where precision varies by magnitude.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:53:41.865058+00:00— report_created — created