Complements of Numbers
Complements of Numbers
Types of
Complements
Ex. 9’s, 1’s, 7’s and 15’s Ex. 10’s, 2’s, 8’s and 16’s
Radix (r) / base complement
Given a number N in base r having ‘n’ digits, r’s complement is defined as (rn - N)
Example : 9’s complement of 865 is: 103 -1 - 865 = 999 - 865 = 134
Addition 7+3
7 → 0111
3 → 0011
1 1 1
0 1 1 1
0 0 1 1
1 0 1 0
1010 → (10)10
Complements of Numbers
Subtraction using 2’s complement 7-3
7 → 0111 0111
3 → 0011 2’s complement 1101
1 1 1 1
0 1 1 1
1 1 0 1
0 1 0 0
Carry generated
and discard it
0100 → (4)10
Complements of Numbers
3 → 0011 0011
7 → 0111 2’s complement 1001
0 0 1 1
0 0 1 1
1 0 0 1
1 1 0 0
No carry
1100 → ?
Complements of Numbers
= -(4)
If final carry NOT generated then Answer = -(2’s complement of result of addition)
Signed Numbers
-0 1000
-1 1001
-2 1010 MSB indicates sign
rest of the bits indicate magnitude
-3 1011
-4 1100
Two representations for 0
-5 1101
(+0 and –0)
-6 1110
-7 1111
Signed numbers (4-bits)
Decimal Positive Positive
Number representation representation Signed 1’s complement
in decimal in binary (Toggle all the bits)
-0 +0 0000 1111
-1 +1 0001 1110
-2 +2 0010 1101
-3 +3 0011 1100
-4 +4 0100 1011
-5 +5 0101 1010
Two representations
-6 +6 0110 1001 for 0
(+0 and –0)
-7 +7 0111 1000
Signed numbers (4-bits)
Decimal Positive Positive
Number representation representation Signed 2’s complement
in decimal in binary (1’s complement +1)
-0 +0 0000 0000
-1 +1 0001 1111
-2 +2 0010 1110
-3 +3 0011 1101
-4 +4 0100 1100
-5 +5 0101 1011
-6 +6 0110 1010
-7 +7 0111 1001
-8 1000
Signed numbers (4-bits)
0 1 1 0 0 1 1
Problems
(1) Represent -51 in
1 0 0 1 1 0 0
1 0 0 1 1 0 1