DC-Lecture 2
DC-Lecture 2
1. Digital Systems
2. Binary Numbers
3. Number-base Conversions
4. Octal and Hexadecimal Numbers
5. Complements
6. Signed Binary Numbers
7. Binary Codes
8. Binary Storage and Registers
9. Binary Logic
Digital Systems & Binary Numbers (Cont.)
Complements
8 1001001
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 10’s Complement
III. If there is a final carry over of the sum, it is dropped and the
result is positive.
IV. If there is no carry over, the 10’s complement of the sum will be
the result and it is negative.
9
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 10’s Complement- Example-1
Minuend Subtrahend r’s Complement is :
rn – N
Evaluate: 72532 – 3250 = [(rn – 1) – N] + 1
= (r-1)’s Complement + 1
– Solution
At first, • The numbers of digits in the subtrahend is 4 while that of
10’s
complem
minuend is 5. We make the number of digits in the subtrahend
ent of the equal to that of minuend by taking a `0’ in the fifth place of the
subtrahe
nd is subtrahend (i.e., 03250).
found. • Now, 10’s complement of 03250 is ([99999 – 03250] +1), i.e.
Then it is 96750. Adding this with the minuend. 1
added to If there is a final
the
• Minued - 7 2 5 3 2 carry over of the
minuend. • 10’s complement of subtrahend + 9 6 7 5 0 sum, it is
dropped and the
• Result of addition- Carry over 1 6 9 2 8 2 result is positive.
IV. If there is no carry over, the 2’s complement of the sum will be the
result and it is negative.
12
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 2’s Complement- Example-1
Minuend Subtrahend If the final carry over of
Evaluate: 110110 – 10110 the sum is 1, it is
dropped and the result
– Solution is positive.
Then it is
• As there is no carry over, the result is negative and the final
added to result will be obtained by:
the
minuend
– Calculate the 2’s complement of the result.
– i.e., 2’s complement of 11100 = (00011 + 00001) = 00100
• Hence, the required difference is – 00100, i.e., – 100
14
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 2’s Complement- Example-3
If the final carry over of the sum
Subtrahend is 1, it is dropped and the result
Minuend
is positive.
Evaluate: 1010.01 – 1001.01
2’s Complement is :
– Solution = 1’s Complement + 1
At first,
• 2’s complement of 1001.01 is (0110.10 + 0000.01) i.e. 0110.11.
2’s Adding this with the minuend. 1
complem
ent of the • Minued - 1010.11
subtrahe • 2’s complement of subtrahend + 0110.11
nd is
found. • Result of addition- Carry over 10001.10
15
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 2’s Complement- Example-4
If there is no carry over, the 2’s
Minuend Subtrahend complement of the sum will be the
result and it is negative.
Evaluate: 10100.01 – 11011.10
2’s Complement is :
– Solution = 1’s Complement + 1
Then it is • As there is no carry over, the final result is negative and it will
added to be obtained by:
the
minuend – Calculate the 2’s complement of the result.
– i.e., 2’s complement of 11000.11 = (00111.00 + 00000.01) =
00111.01
16 • Hence, the required difference is – 00111.01
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 1’s Complement
iii. If the result of addition has a carry over then it is dropped and
an 1 is added in the last bit.
17
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 1’s Complement- Example-1
If the result of addition has a carry over
Minuend Subtrahend then it is dropped and an 1 is added in
the last bit.
Evaluate: 110101 – 100101
– Solution
• 1’s complement of 100101 is 011010.
Write
• Minued - 1 110101
down 1’s
complem • 1’s complement of subtrahend + 011010
ent of the
subtrahe • Result of addition- Carry over 1 001111
nd.
+ 000001
To add
this with
010000
the
minuend
• As there is a carry over, it is dropped and 1 is added in
the last bit.
• The required difference is 10000
18
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 1’s Complement- Example-2
If there is no carry over, then 1’s
Minuend Subtrahend complement of the result of addition is
obtained to get the final result and it is
Evaluate: 101011 – 111001 negative.
– Solution
• 1’s complement of 111001 is 000110.
Write
down 1’s • Minued - 101011
complem • 1’s complement of subtrahend + 000110
ent of the
subtrahe • Result of addition- No Carry over 110001
nd.
To add
this with
• As there is no carry over, the final result is negative and
the it will be obtained by:
minuend
– Calculate the 1’s complement of the result.
– i.e., 1’s complement of 110001 is 001110
• Hence, the required difference is – 001110 i.e. – 1110
19
Digital Systems & Binary Numbers (Cont.)
Complements (Cont.)- Arithmetic Subtraction by Complements-
Subtraction by 1’s Complement- Example-3
If there is no carry over, then 1’s
Minuend Subtrahend complement of the result of addition is
obtained to get the final result and it is
Evaluate: 10110.01 – 11010.10 negative.
– Solution
• 1’s complement of 11010.10 is 00101.01.
Write
down 1’s • Minued - 1 0 1 1 0. 0 1
complem • 1’s complement of subtrahend + 0 0 1 0 1. 0 1
ent of the
subtrahe • Result of addition- No Carry over 1 1 0 1 1. 1 0
nd.
To add
this with
• As there is no carry over, the final result is negative and
the it will be obtained by:
minuend
– Calculate the 1’s complement of the result.
– i.e., 1’s complement of 11011.10 is 00100.01
• Hence, the required difference is – 00100.01 i.e. – 100.01
20
Outline
1. Digital Systems
2. Binary Numbers
3. Number-base Conversions
4. Octal and Hexadecimal Numbers
5. Complements
6. Signed Binary Numbers
7. Binary Codes
8. Binary Storage and Registers
9. Binary Logic
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers
22
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers-
Arithmetic Addition by Complements-
Addition by 2’s Complement
23
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers-
Arithmetic Addition by Complements- Addition by 2’s Complement-
1. Addition of a Positive number & a Negative number- Case I
Example-2: In a 5-bit register find the sum of the following by using 2’s
complement: + 0111 and – 0011.
1
+0111 001112
- 0011 + 111012 2’s Complement
=
Carry 1 discarded 1001002 1100 1’s Complement
+ 0001
---------
1101
25
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers-
Arithmetic Addition by Complements- Addition by 2’s Complement-
1. Addition of a Positive number & a Negative number- Case II
Example-2: In a 5-bit register find the sum of the following by using 2’s
complement: + 0100 and – 0111
Solution: +0100 + (-0111) = +0100 – (+0111) (Subtraction by 2’s complement)
+0100 001002
- 0111 + 110012 2’s Complement
=
No carry over 111012 1000 1’s Complement
+ 0001
---------
1001
̶ As there is no carry over, the result is negative and the final result will be
obtained by taking 2’s complement of 1101= (0010 + 0001) = 0011.
̶ Hence the required sum is – 0011.
27
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers-
Arithmetic Addition by Complements- Addition by 2’s Complement-
2. Addition of two Negative numbers
̶ In this case, a carry will be generated from the sign bit which will be
discarded. The negative of 2’s complement of the magnitude bits of the
operation will be the final sum.
Example-1: In a 5-bit register find the sum of the following by using 2’s
complement: – 0011 and – 0101
Solution:
1
- 0011 111012 2’s Complement
- 0101 + 110112 2’s Complement
Carry 1 discarded 1110002
̶ As there is a carry over, the result is negative and the final result will be
obtained by taking 2’s complement of 1000= (0111 + 0001) = 1000.
̶ Hence the required sum is – 1000.
28
Digital Systems & Binary Numbers (Cont.)
Signed Binary Numbers-
Arithmetic Addition by Complements- Addition by 2’s Complement-
2. Addition of two Negative numbers (Cont.)
Example-2: In a 5-bit register find the sum of the following by using 2’s
complement: – 0111 and – 0010.
Solution:
1
- 0111 110012 2’s Complement
- 0010 + 111102 2’s Complement
Carry 1 discarded 1101112
̶ As there is a carry over, the result is negative and the final result will be
obtained by taking 2’s complement of 0111= (1000 + 0001) = 1001.
̶ Hence the required sum is – 1001.
29