Digital Logic and Design Lecture # 4: (AMD X4 Proc Photo: Sc. Am, Jan. 2010)
Digital Logic and Design Lecture # 4: (AMD X4 Proc Photo: Sc. Am, Jan. 2010)
Lecture # 4
9 9 9 9 9 9
Find the 9’s complement of 546700 and
12389 - 5 4 6 7 0 0
4 5 3 2 9 9
The 9’s complement of 546700 is 999999 -
546700= 453299
9 9 9 9 9
1 1 1 1 1
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
1’s complement
Find r-1 complement for binary number N with four binary digits.
r-1 complement for binary means 2n -1 complement or 1’s
complement.
n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2.
The l’s complement of N is (24 - 1) - N. = (1111) - N
1’s complement
1 1 1 1 1 1 1
1011001 is 0100110 0 1 0 0 1 1 0
1 1 1 1 1 1 1
0001111 is 1110000 1 1 1 0 0 0 0
r’s Complement
•100000……. - N
10’s complement Examples
1 0 0 0 0 0
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
2’s complement Example
1 0 0 0 0 0 0 0
0 1 0 0 1 1 1
1 0 0 0 0 0 0 0
The 2’s complement of
0001111 is 1110001
- 0 0 0 1 1 1 1
1 1 1 0 0 0 1
Fast Methods for 2’s Complement
Method 1:
The 2’s complement of binary number is obtained by adding 1 to the
l’s complement value.
Example:
1’s complement of 101100 is 010011 (invert the 0’s and 1’s)
2’s complement of 101100 is 010011 + 1 = 010100
Fast Methods for 2’s Complement
Method 2:
The 2’s complement can be formed by leaving all least significant 0’s
and the first 1 unchanged, and then replacing l’s by 0’s and 0’s by l’s
in all other higher significant bits.
Example:
The 2’s complement of 1101100 is
0010100
Leave the two low-order 0’s and the first 1 unchanged, and then
replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
Examples
– Finding the 2’s complement of (01100101)2
• Method 1 – Simply complement each bit and then add
1 to the result.
(01100101)2
*N+ = 2’s complement = 1’s complement (10011010)2 +1
=(10011011)2
• Method 2 – Starting with the least significant bit, copy
all the bits up to and including the first 1 bit and then
complement the remaining bits.
N =01100101
[N] =10011011
Subtraction of Numbers
using r’s complement
Subtract N from M : M – N
M = 13250
10’s complement of N = +27468
Sum = 40718