2s Complement of a negative zero

2.7k Views Asked by At

I have problem: you know the 2s Complement so you can get the negative number of a positive one with the reverse and adding a one. e.g.

8 Bit
121 = 0111 1001
 1st= 1000 0110
  +   0000 0001
      ---------
      1000 0111 --> -121 

So now if we have a -0

a zero looks as 8 bit

0000 0000

so a minus 0 should look

 1111 1111 + 0000 0001
= 10000 0000

but that is 512

so I think that I've misunderstood something

2

There are 2 best solutions below

3
On BEST ANSWER

1 0000 0000b is 256, not 512. Truncated to 8 bits, it's 0.

This is because with two's complement, zero is zero. There is no positive or negative zero.

Compare this to one's complement or sign bit, where positive zero and negative zero are different values.

0
On

To expand my previous comment to the question

1111 1111 + 0000 0001 in 8 bit is 0000 0000, the ninth bit is lost because there is no place from it.

And, yes the complement of a negative is a positive

-121 = 1000 0111
 1st = 0111 1000
   +   0000 0001
       ---------
       0111 1001 --> 121 

Think of them as a circle, at one point there is 0, adding 1 at a time you go up to the opposite point (128 in 8 bit) at that point the sign is switched and the absolute value begin to decrease, e.g.: 128 + 1 = -127, as you continue to add 1 the value go back to 0 and the circle is completed.

So given a number of bit, you only have that much bit, no more, and if you want the value to be signed you really have only x-1 bit for the value, as the most significant bit is used for the sign (0 -> +; 1 -> -)