[Poll] What do you get if you add two negative zeroes in JavaScript?
-0 + -0
No cheating! #jsquiz
-
-
Confused why so many comments think this is qwirky. The sign not flipping follows the behaviour of all other negative numbers
-
+1 https://twitter.com/mathias/status/957407446116442112 … Maybe just the fact that it’s JavaScript is enough to cause confusion

- 1 more reply
New conversation -
-
-
So I got that right. But I'm still puzzled that -0 + 0 is +0, though. I still have to find a sense of it.

-
It actually kind of makes sense! Replace 0 in your example (or in mine) with any other number. What result do you expect?
- 1 more reply
New conversation -
-
-
a fun detail of negative zero is that `0 - x` and `-x` are NOT equivalent. however, `-0 - x` (I think) or `-1 * x` are.
-
This was the cause of a bug in PHP, which used to compile negations as subtractions from zero (why have a negation opcode?), and thus `-0.0` didn't produce negative zero. I fixed it by multiplying by -1 instead.
End of conversation
New conversation -
-
-
Yeah, I was right :-) One time intuition leads one in the right direction with JavaScript. Pub quiz winner, drinks on me!
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
This Tweet is unavailable.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.