0
votes

One way to represent the signed numbers is using the sign bit.

Another way is using the 2's Complement? Am i correct?

If yes, consider the number 8. Equalent binary is 0000 1000

Then According to 2's Complement method.

  1. We will invert the bit so, 0000 1000 becomes 1111 0111 2.Add one to it so 1111 0111 becomes 1111 1000.

with 1111 1000. how they are representing the sign bits?

2

2 Answers

0
votes

In 2's complement the Most Significant Bit represents a negative value. So for an 8 bit number the decimal equivalent of each bit is:

-128 64 32 16 8 4 2 1

Hence 11111000 sums to -8.

0
votes

The "sign bit" would be the leftmost one: 0 - positive, 1 - negative. Another way to look at it would be (assuming 8-bit numbers):

number 8 -> 1000
+8: fill from the leftmost 1 leftwards with sign bit 0 = positive -> 0000 1000
-8:  fill from the leftmost 1 leftwards with sign bit 1 = negative -> 1111 1000

So when you work in 2's complement you actually have a varying number of "sign bits", in that example you have 4.

UPDATE:

Got it wrong above, where it says "leftmost", it should read "rightmost"