JavaScript addition using the new and upcoming Math.sumPrecise():

❌ 1 + 0.1 - 1 = 0.10000000000000009
✅ Math.sumPrecise([1,.1,-1]) = 0.1

❌ 1e20 + 0.1 - 1e20 = 0
✅ Math.sumPrecise([1e20,.1,-1e20]) = 0.1

❌ 0.1 + 0.2 = 0.30000000000000004
❌ Math.sumPrecise([.1,.2]) = 0.30000000000000004

Math.sumPrecise() - JavaScript | MDN
The Math.sumPrecise() static method takes an iterable of numbers and returns the sum of them. It is more precise than summing them up in a loop, because it avoids floating point precision loss in inte...