Negative Zero -0 (yes, it’s a thing:)

Negative zero is the condition where all bits in a signed byte are 1. This follows the ones’ complement rules that a value is negative when the left-most bit is 1, and that a negative number is the bit complement of the number’s magnitude. The value also behaves as zero when computing. Adding or subtracting negative zero to/from another value produces the original value.

Binary code goes from right to left, so, for unsigned bytes:

000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7

But with a signed byte, where the first bit means negative:

000    0
001    3
010    2
011    1
100   -1
101   -2
110   -3
111   -0

And it is demonstrated by simple addition:

001   3
+110   -3
====  ==
=111   -0

010    2
+101   -2
====  ==
=111   -0

011    1
+100    -1
====  ==
=111   -0

 

−1510 to +1510 can be represented by a signed 4-bit byte
−12710 to +12710 can be represented by a signed 8-bit byte

And so on.

The number 0 is usually encoded as +0, but can be represented by either +0 or −0.

The pair is regarded as equal by the numerical comparison operations, but with possible different behaviors in particular operations.