Re:How does your programming language handle “minus zero” (-...
by kzemek on Friday March 05, 2021 @07:18AM
(#26355999)
Isn't that true for all correct implementations of negative zero? It's still a neutral for addition
[ Parent
| on HN ]
Re:How does your programming language handle “minus zero” (-...
by worc3131 on Friday March 05, 2021 @07:32AM
(#26356110)
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
Re:How does your programming language handle “minus zero” (-...
by thaumasiotes on Friday March 05, 2021 @07:42AM
(#26356199)
> Not quite neutral.
Hmm? Your examples show -0.0 being additively neutral in every case. +0.0 is the one that behaves weirdly.