look at the string of bits (zeros and ones) there is no indicator whether or
or “-” to indicate the sign of the number. There are some types of number
bits. Such representations are referred as SIGNED representations because you
can determine the sign of the number from the number itself.
In signed representations you the MOST SIGNIFICANT BIT (MSB) indicates the sign
of the number. The MSB is the left most bit. If the MSB is equal to 0 then the
number is positive. If the MSB is equal to 1 then the number is negative.
e.g. 001111101 is positive
The MSB is equal to zero
e.g. 101101010 is negative
The MSB is equal to one
At this point you might ask yourself why bother with signed representations –
we perform decimal based subtractions in every day life using base ten
reason why it’s important to learn about signed representations is because
when the computer tries to subtract one number Y from another number X, it
Instead it uses a technique known as negating and adding:
i.e. X + (-Y) which is still equal to X – Y
CONVERSIONS (UNSIGNED BINARY TO SIGNED VALUES)
1’s complement 2’s complement
Binary value >= 0 No change No change
Binary value < 0 Swap the bits Swap the bits and add
one to the result.
Carry out? Add it back in Ignore it
Swapping the bits means we substitue 1’s for 0’s and 0’s for 1’s.
DOING SUBTRACTIONS VIA COMPLEMENTS (ala Negate and Add)
How do we do this with the negate and add? First convert these numbers to
Base 10 Base 2 (must be signed!)
eg 4 0100
*I added one extra zero to the left hand side as an extra placeholder. When
I convert these numbers to signed values, this digit it will represent the
minus six in this form. It must be converted to a SIGNED VALUE. You can
use either a 2’s complement representation or a 1’s complement representation.
But make sure that you keep straight which one you use (don’t switch halfway
thru a computation between a 1’s and 2’s complement representation or vice
Number to convert 1’s complement 2’s complement
(flip bits)* (flip bits + 1)*
-0110 1001 1010
1’s complement way 2’s complement way
Number from above (4) 0100 0100
The complemented number 1001 1010
Summed Result 1101 1110
Convert to this value
from a complemented
form to regular binary -0010 -0010
Convert from binary -2 -2
Notice that there is no carry out so we con’t have to worry about addding in
the overflow or ignoring it.
*But this conversion only occurs for negative numbers. Look again at the
circles that I drew in lab, a positive number is a positive number number
matter what binary representation that you use. That means that if the
MSB is equal to a zero, when we get to the second last step, when we try
to find the equivilent unsigned binary value no conversions are necessary.
A positive unsigned digit will look the same in signed (1’s and 2’s
Done using 1’s complement:
Base 10 Base 2
Now here’s comes the fun stage, molding the unsigned base two numbers into
signed one’s and two’s complement representations.
Base 2 Add zero to left* Convert to 1’s complement
1010 01010 01010**
0011 00011 11100
Add the numbers 10 + (-3):
Overflow=> 1 00110
Goes here -> +1