Digital Logic &
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
Outline Binary number system
1’s complement
2’s complement
of the Subtraction using 1’s complement
Subtraction using 2’s complement
‘r’ number system
lecture (r-1)’s complement
(r)’s complement
Subtraction using (r-1)’s complement
Subtraction using (r)’s complement
Comparisons
Representation of signed numbers
Problems for practice
2
Need for complements
For any radix ‘r’ number system, there exists two
complements:
(r-1) complement
(r) complement
Complements help in converting the arithmetic
subtraction operation into arithmetic addition
operation.
Hence, all arithmetic operations i.e. addition,
subtraction, multiplication and division can be
performed using only adders.
Decimal number system
9’s Complement
Is obtained by subtracting each digit in the number from 9
e.g. 9’s complement of 4397 = 9999 − 4397 = 5602
e.g. 9’s complement of 678.42 = 999.99 − 678.42 = 321.57
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
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
+ 0 1 0 1 1’s complement of 1010
No Carry 1 1 0 1 Sum
− 0 0 1 0 1’s complement of 1101
Result
Binary number system
Subtraction using 2’s Complement
Smaller binary number from a larger one
— add the 2’s complement of the subtrahend (number to
be subtracted) to the minuend
— discard the carry generated (there is always in this
case)
e.g. 1100 – 1001 = 1100 + (2’s complement of 1001)
1 1 0 0 Minuend
+ 0 1 1 1 2’s complement of 1001
Carry
discarded 1 0 0 1 1 Sum
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
+ 0 1 0 0 2’s complement of 1100
No Carry 1 1 0 0 Sum
− 0 1 0 0 2’s complement of 1100
Result
Radix ‘r’ numbeR system
(r-1)th Complement
(r-1)th = rn – r-m - N
where, r is the radix or base
n is number of maximum digits before decimal
m is number of maximum digits after decimal
N is the number to be subtracted
e.g. (201)10 – (101)10 using (r-1)th complement,
i.e. (10-1)th = 9th complement 2 0 1 Minuend
For (101)10, 9th complement = 103 – 10-0 – 101 + 8 9 8 9’s complement of 101
Carry 1 0 9 9 Sum
= 1000 – 1 – 101
+ 1 Carry
= 1000 – 102 = 898 Result
1 0 0
For subtraction: 201 + 898 = 1099,
add carry, result is 100
Radix ‘r’ numbeR system
rth Complement
rth = rn - N
where, r is the radix or base
n is number of maximum digits before decimal
N is the number to be subtracted
e.g. (2365)10 – (3625)10 using rth complement,
i.e. 10th complement
For (3625)10, 10th complement = 104 – 3625
= 10000 – 3625
= 6375
2 3 6 5 Minuend
For subtraction: 2365 + 6375 = 8740
+ 6 3 7 5 10’s complement of 3625
No carry, result is (-1260)
No Carry 8 7 4 0 Sum
− 1 2 6 0 10’s complement of 8740
Result
Comparison
1’s complement 2’s complement
Easily obtained using an Obtained by adding one
inverter unit to 1’s complement
Used in logical Used for arithmetic
manipulation for applications such as
inversion operation adders
Requires 2 operations: Requires 1 operations:
Logical operation Logical operation
End around carry
Representation of signed
numbers
In all number systems, both positive and
negative numbers are possible
Positive numbers represented by ‘+’
Negative numbers represented by ‘−’
Negative Binary numbers are represented
by
Sign Magnitude representation
1’s complement representation
2’s complement representation
Representation of signed
numbers
Sign Magnitude Representation
Extra bit is added at left most end, known as
Sign bit
‘+’ is denoted by ‘0’
‘−’ is denoted by ‘1’
eg: +1000101 is represented as
0 1 0 0 0 1 0 1
Sign bit Magnitude of the number
−1000101 is represented as
1 1 0 0 0 1 0 1
Sign bit Magnitude of the number
Representation of signed
numbers
1’s Complement Representation
Positive number is denoted with ‘0’ as Sign
bit and true binary value as magnitude
Negative number is denoted with ‘1’ as Sign
bit and magnitude in 1’s complement form
eg: +11 is represented as
0 0 0 0 1 0 1 1
Sign bit Magnitude of the number
−11 is represented as
1 1 1 1 0 1 0 0
Sign bit 1’s complement of the number
Representation of signed
numbers
2’s Complement Representation
Positive number is denoted with ‘0’ as Sign
bit and true binary value as magnitude
Negative number is denoted with ‘1’ as Sign
bit and magnitude in 2’s complement form
eg: +73 is represented as
0 1 0 0 1 0 0 1
Sign bit Magnitude of the number
−73 is represented as
1 0 1 1 0 1 1 1
Sign bit 2’s complement of the number
1. (18 - 6) using 9’s complement
2. (21 - 38) using 9’s complement
3. (347 - 265) using 10’s complement
4. (74 - 85) using 10’s complement
5. (1111 - 1010) using 1’s complement
6. (1000 - 1100) using 1’s complement
7. (1111 - 1010) using 2’s complement
8. (1000 – 1010) using 2’s complement
Problems 9. (1011.01)2 – (1100.00)2 using (r-1)th
complement
10. Represent (-31)10 and (-99)10 in
a) 8-bit binary signed magnitude
representation.
b) 2’s complement representation
c) 1’s complement representation
21