tc39 / proposal-math-sum

TC39 proposal to add a summation method to JavaScript
https://tc39.github.io/proposal-math-sum
72 stars 1 forks source link

Empty list sums to 0 or -0? #5

Closed bakkot closed 3 months ago

bakkot commented 4 months ago

-0 is in some sense more correct, at least if you're thinking about floats: -0 is the additive identity for floats. On the other hand, this is supposed to be approximating real-number arithmetic as closely as possible, and reals do not have -0.

As a datapoint, in Python fsum([]) gives 0, not -0.

michaelficarra commented 3 months ago

I prefer -0.

bakkot commented 3 months ago

-0 it is.