Hacker News new | ask | show | jobs
by worc3131 1938 days ago
Not quite neutral. You return -0.0 only when needed.

  >>> 0.0+0.0
  0.0
  >>> 0.0+(-0.0)
  0.0
  >>> (-0.0)+0.0
  0.0
  >>> (-0.0)+(-0.0)
  -0.0
2 comments

> Not quite neutral.

Hmm? Your examples show -0.0 being additively neutral in every case. +0.0 is the one that behaves weirdly.

heh, looks like abs(-0.0) is slightly less than abs(+0.0)!