Lecture2 Complements
Lecture2 Complements
Computer
Design(DL&CD)
Theory - ECC-207
B. Tech – 3rd Sem
Faculty: Dr. Anubha Goel
Complement of a number
Decimal number system
9’s complement
10’s complement
Subtraction using 9’s complement
Subtraction using 10’s complement
Comparisons
Representation of signed numbers
Problems for practice
2
Need for complements
10’s Complement
Is obtained by adding ‘1’ to right most digit of 9’s complement of the
number
e.g. 10’s complement of 4397 = (9999 − 4397) + 1 = 5603
e.g. 10’s complement of 678.42 = (999.99 − 678.42) +1 = 321.58
9 9 9 9 9 9 9 . 9 9
− 4 3 9 7 Number − 6 7 8 . 4 2 Number
5 6 0 2 9’s complement 3 2 1 . 5 7 9’s complement
+ 1 + 1
5 6 0 3 10’s complement 3 2 1 . 5 8 10’s complement
Decimal number system
Subtraction using 9’s Complement
Smaller decimal number from a larger one
— add the 9’s complement of the subtrahend
(number to be subtracted) to the minuend
— add the carry generated to the obtained sum
e.g. 99 - 83 = 99 + (9’s complement of 83)
9 9 Minuend
+ 1 6 9’s complement of 83
Carry 1 1 5 Sum
+ 1 Carry
Result 1 6
Decimal number system
Subtraction using 9’s Complement
Larger decimal number from a smaller one
— add the 9’s complement of the subtrahend
(number to be subtracted) to the minuend
— no carry is generated
— the result is negative with magnitude in 9’s
complement form
e.g. 34 - 49 = 34 + (9’s complement of 49)
3 4 Minuend
+ 5 0 9’s complement of 49
No Carry
8 4 Sum
− 1 5 9’s complement of 84
Result
Decimal number system
Subtraction using 10’s Complement
Smaller decimal number from a larger one
— add the 10’s complement of the subtrahend
(number to be subtracted) to the minuend
— discard the carry generated
e.g. 54 – 36 = 54 + (10’s complement of 36)
5 4 Minuend
+ 6 4 10’s complement of 36
Carry
discarded 1 1 8 Sum
Result 1 8
Decimal number system
Subtraction using 10’s Complement
Larger decimal number from a smaller one
— add the 10’s complement of the subtrahend (number to
be subtracted) to the minuend
— no carry is generated
— the result is negative with magnitude in 10’s
complement form.
e.g. 28 - 63 = 28 + (10’s complement of 63)
2 8 Minuend
+ 3 7 10’s complement of 63
No Carry
6 5 Sum
Result − 3 5 10’s complement of 65
binary number system
1’s Complement
Is obtained by subtracting each digit in the number from 1
OR change all 1’s to 0 and all 0’s to 1
e.g. 1’s complement of 11010 = 11111-11010 = 00101
2’s Complement
Is obtained by adding ‘1’ to right most digit of 1’s
complement of the number
e.g. 2’s complement of 1001 = 1’s complement +1
= (1111 - 1001) + 1
= 0110 +1
= 0111
binary number system
Subtraction using 1’s Complement
Smaller binary number from a larger one
— add the 1’s complement of the subtrahend (number to
be subtracted) to the minuend
— add the carry generated to the obtained sum. This is
referred as END-AROUND-CARRY
e.g. 11101 - 10101 = 11101 + (1’s complement of 10101)
1 1 1 0 1 Minuend
+ 0 1 0 1 0 1’s complement of 10101
Carry 1 0 0 1 1 1 Sum
+ 1 Carry
Result 0 1 0 0 0
binary number system
Subtraction using 1’s Complement
Larger binary number from a smaller one
— add the 1’s complement of the subtrahend (number to
be subtracted) to the minuend
— no carry is generated
— the result is negative with magnitude in 1’s
complement form.
e.g. 1000 - 1010 = 1000 + (1’s complement of 1010)
1 0 0 0 Minuend
1 1 0 0 Minuend
0 0 1 1
Result
Binary number system
Subtraction using 2’s Complement
Larger binary number from a smaller one
— add the 2’s complement of the subtrahend (number to
be subtracted) to the minuend
— no carry is generated
— the result is negative with magnitude in 2’s
complement form
e.g. 1000 - 1100 = 1000 + (2’s complement of 1100)
1 0 0 0 Minuend
No Carry 1 1 0 0 Sum
−1000101 is represented as
1 1 0 0 0 1 0 1
−11 is represented as
1 1 1 1 0 1 0 0
−73 is represented as
1 0 1 1 0 1 1 1
21