[issue26324] sum() incorrect on negative zeros

2016-02-10 Thread Jim Jewett
Jim Jewett added the comment: Even if Ethan's argument about an explicit start value were not convincing, Mark + Raymond would count as authoritative for floats. Anyone can reopen if needed; I just don't want the issue to languish forever if there is at least grudging agreement. --

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Antoine Pitrou
New submission from Antoine Pitrou: >>> sum([-0.0,-0.0]) 0.0 -- components: Interpreter Core messages: 259961 nosy: eric.smith, lemburg, mark.dickinson, pitrou, stutzbach priority: low severity: normal status: open title: sum() incorrect on negative zeros type: behavior versions: Python

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: "Expect" is a strong word here ;-) The problem is the start value is implicit and is supposed to be a "good default". Of course, solving this consistently may not be trivial. -- ___ Python tracker

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Emanuel Barry
Emanuel Barry added the comment: This is consistent with the advertised equivalence of sum(): >>> -0.0 + -0.0 + 0 0.0 This works as you'd expect: >>> sum([-0.0, -0.0], -0.0) -0.0 It has a start value of 0, and I don't think we should special-case this. -- nosy: +ebarry

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Emanuel Barry
Emanuel Barry added the comment: "Not trivial" might be an understatement. You need the start value to begin summing the items, but you may face with a non-repeatable generator with side-effects. Sure, you could special-case some builtins, but I'm not too keen on adding special cases for such

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Ethan Furman
Ethan Furman added the comment: If one is using sum on floats, and a list of -0.0's is a possibility, and the sign matters... well, I would hope that one is using -0.0 as the start value. I don't think this is worth "fixing". -- nosy: +ethan.furman

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Mark Dickinson
Mark Dickinson added the comment: For what it's worth, NumPy has exactly the same behaviour: >>> np.array([-0.0, -0.0]).sum() 0.0 ... which is a bit surprising, given that this is a much easier problem to fix when you know the type of everything in the array in advance. The Decimal type has

[issue26324] sum() incorrect on negative zeros

2016-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I think it's best left as it is I concur. -- nosy: +rhettinger ___ Python tracker ___