Problem | Take 2's compl. of
negative number |
add
it to the other number |
(a)
Drop the carry bit, or... |
(b)
Convert from 2's compliment form |
Decimal equivalent of
problem |
11010 -10111 |
-10111=>>01000+1 =01001 |
11010 + 01001 =100011 |
00011 |
26 -23 = +3 |
|
1011 -10010 |
-10010=>>01101+1 =01110 |
01011 +01110 =11001 |
(no
carry) |
11001=>00110+1 =00111 (negative) |
11 -18 = -7 |
11000101 - 1111011 |
(note
leading zero added) -01111011=>>10000100+1 =10000101 |
11000101 + 10000101 =101001010 |
01001010 |
197 -123 = 74 |
|
11000101 -11101010 |
11101010=>>00010101+1 =00010110 |
11000101 + 00010110 = 11011011 |
(no carry) | 11011011=>00100100+1 =00100101(negative) |
197 -234 = -37 |
Number | Take compliment of each bit |
add one |
2's compliment |
11010 |
11010=>>00101 |
00101 + 1 = 00110 |
00110 |
111111 |
111111=>>000000 |
000000 + 1 =000001 |
00001 |
100000 |
100000=>>011111 |
011111 + 1 = 100000 |
100000 |
00110 | 00110=>>11001 |
11001 + 1 = 11010 |
11010 |