# What is the difference between $0$ and $-0$?

Why is there a $0$ and a $-0$? I thought zero meant nothing, so how can we have negative nothing?

-
@Stahl how is this relevant? – gt6989b Mar 21 '13 at 21:44
The idea of $0$ being positive or negative might have to do with the confusion between $0$ and $-0$. The first answer and others state that typically $0$ is unsigned, and thus would give another reason that $0 = -0$. Since that's not the answer I was going to post, I just thought it might provide another perspective on "$0$" vs. "$-0$." – Stahl Mar 21 '13 at 21:49

People often have an unspoken assumption, that, basically

$$\text{If it looks different, it is different}$$

until they learn otherwise, and this is just one of many cases where that isn't true. $0=-0$. And $1=1.0$. And $1/2=2/4=3/6$. And $0.999...=1$. There are plenty of cases where there are multiple ways of writing the same thing down. Writing the negative in $-0$ is perfectly possible, but redundant, because it's just $0$ anyway. So in a sense you can have "negative nothing", but it's just the same as good old regular "nothing".

N.B. In some computer systems this isn't technically the case. If you represent negative numbers with one's complement then you do in fact have two zeroes, and it is sensible to call one of them $-0$. Mathematically we still have $0=-0$ (i.e. they still behave the same way under various operations), but they're stored as two distinct numbers. This is kind of inconvenient, and so we normally use two's complement instead, where there's only one zero.

-
Floating point numbers also have multiple representations for zero, since in the encoding there is one bit that represents the sign of the number. Interestingly, the two different representations for zero in floating-point arithmetic actually behave differently in many implementations: 1/0 will return Infinity, whereas 1/-0 will return -Infinity. – Peter Olson Mar 22 '13 at 0:59
@PeterOlson I seem to believe that this is required by IEEE 754. – Kaz Mar 22 '13 at 19:54
@Kaz Yes, I think it is. I said "many implementations" just because there are probably some non-conformant languages, as well as some languages that always throw an exception on division by zero. – Peter Olson Mar 22 '13 at 20:01

For a number $x$, $-x$ denotes the unique $y$ such that $x+y=0$. In the case for $x=0$ we have that $-x=0$ as well.

-

Normally, given a number $a$, the number $-a$ is the additive inverse of $a$: i.e., $-a$ is the number that satisfies $a + (-a) = e$, where $e$ is the additive identity. Since $e + e = e$ by definition of an additive identity, we see that $e = -e$. In the case of $\Bbb{Z}$, $\Bbb{Q}$, $\Bbb{R}$, $\Bbb{C}$, and related objects, $0$ is the additive identity, so $0 = -0$.

-

Aha, computer science question!

This shows that a sign-magnitude (or one's complement) representation is being used, leading to two zeros with a different sign bit.

(I'm ducking under the desk now to avoid being struck by projectile office supplies).

-

In floating point arithmetic $0$ and $-0$ are different. If you take a positive number $x$ you will get $x/0=\infty$ and $x/(-0)=-\infty$.

-

To take the question (possibly a little too) literally, the difference between two numbers, $x$ and $y$ is given by $|x-y|$. Letting $x=0, y=-0$:

\begin{align*} |x-y| &= |0-(-0)| \\ &= |0+0| \\ &= |0| \\ &= 0 \end{align*}

So there's no difference between them at all :)

-