0380. Show how you would subtract 76 from 35 using
both one’s compliment and two’s compliment.
76 = 10011002 Or 00000000010011002 (On 16-bits)
35 = 1000112 Or 00000000001000112 (On 16-bits)
ONE’S Compliment:
-76 (in one’s compliment) would be:
0000000001001100
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
1111111110110011
Subtracting 76 from 35 (35 + -76)
would yield:
0000000000100011 (+35)
+ 1111111110110011 (-76)
1111111111010110
NOTE: Since the result is negative,
we do not need to add 1. However, we must compliment to make sense of the
result:
1111111111010110
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
0000000000101001
Check:
00000000001010012 = -(32 + 8 + 1) = -41 (correct)
TWO’S Compliment:
-76 (in two’s compliment) would be:
1111111110110011
+ 1
1111111110110100
Subtracting 76 from 35 (35 + -76)
would yield:
0000000000100011 (+35)
+ 1111111110110100 (-76)
1111111111010111
Compliment:
1111111111010111
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
0000000000101000
And add 1:
0000000000101000
+ 0000000000000001
0000000000101001
Check: 00000000001010012 = 25 + 23 = 32 +
8 +1 = 41
(correct)