Professional Documents
Culture Documents
2
Complements of Binary Numbers
• 1’s complement
• Change all 1s to 0s and all 0s to 1s
1 0 1 0 1 0 1
0
0 1 0 1 0 1 0
1
3
Complements of Binary Numbers
• 2’s complement
• Find 1’s complement and then add 1
1 0 1 0 1 0 1
1
0
1’s 0 1 0 1 0 1 0
complement 1 Input bits
Carr
Adder (add 1)
y
Output bits (sum)
In
2’s 0 1 0 1 0 1 1
4
complement 0
Negative Binary Numbers
• 1210 = 00001100
• -1210 = 10001100
• How many representations are there for zero?
One’s Complement
• 1110 = 00001011
• -1110 = 11110100
• 1110 = 00001011
• -1110 = 11110100 one’s comp
• -1110 = 11110101 two’s comp
Subtraction by Addition
• 00001010 10
• 00000110 6
• 00000100 subtract gives 4
Two’s complement
• -6
• 0001010 10
• 11111010 6
• (1) 00000100 adding gives 4
.
Why two’s complement