JavaScript's Math.sumPrecise() eliminates floating-point summation errors
JavaScript now has Math.sumPrecise(), which returns the exact sum of an iterable of numbers with a single final rounding, so the result no longer depends on order. It reached Baseline in April 2026 in Chrome and Edge 147, Firefox 137 and Safari 26.2, but is still missing in Node.js 24.11.
- Math.sumPrecise([0.1, 0.2, 0.3]) returns 0.6, while reduce() gives 0.6000000000000001
- Summing 1000 values of 0.1 yields 100 versus 99.9999999999986 with a loop
- Supported in Chrome and Edge 147, Firefox 137, Safari 26.2; absent in Node.js
- Summing a million numbers took ~4 ms versus ~16 ms with reduce()
Read next
Software