0% found this document useful (0 votes)
3 views

Lecture 3

The document outlines key concepts in digital logic design, focusing on binary arithmetic operations such as addition, subtraction, and multiplication, as well as conversions between signed binary and decimal numbers. It includes examples and practice problems to illustrate these concepts. The document also discusses the use of 2's complement for representing negative numbers in binary arithmetic.

Uploaded by

acernitro88588
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 3

The document outlines key concepts in digital logic design, focusing on binary arithmetic operations such as addition, subtraction, and multiplication, as well as conversions between signed binary and decimal numbers. It includes examples and practice problems to illustrate these concepts. The document also discusses the use of 2's complement for representing negative numbers in binary arithmetic.

Uploaded by

acernitro88588
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
You are on page 1/ 13

EE227 – Digital Logic Design

Lecture 3
Outline
• Binary Addition, Subtraction and
Multiplication
• Conversion of signed fractions from binary
to decimal and vice versa
• Subtraction with Complements

EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 2


Binary Addition
• Let’s illustrate the binary addition with an
example
• Add 1001011 and 0101011

Carry 0010110
Number A 1001011
Number B 0101011
Sum 1110110
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 3
Binary Subtraction
• Let’s illustrate the binary addition with an
example
• Subtract 1010 from 1100

Borrow 0 0 10 0
Number A 1 1 0 0
Number B 1 0 1 0
Difference 0 0 1 0
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 4
Binary Multiplication
• Let’s illustrate the binary addition with an
example
• Multiply 1011 with 101
+001011
x000101
Partial Product
+001011
Partial Product
+000000
Partial Product
+101100
Final Product
+110111
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 5
Practice Problem 1
i. Add the signed (10110111)2 and
(01010111)2 and verify that answer is
correct Answer is (14) 10

ii. Subtract unsigned (111)2 from (11000)2


and verify that answer is correct Answer is (17) 10

iii. Multiply unsigned (11011)2 with (1011)2


and verify that answer is correct
Answer is (297)
10

EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 6


Signed Binary to Decimal Conversion
(1/2)
• If MSB is 0
– Convert the binary number to decimal like unsigned
number
Example
Convert signed (0100 1100)2 to decimal equivalent
Solution
As MSB is 0 so number is positive
Dec = (1 x 26) + (1 x 23) + (1 x 22)
Dec = 64 + 8 + 4
Dec = 76
 (0100 1100)2 = (+76)10
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 7
Signed Binary to Decimal Conversion (2/2)
• If MSB is 1, then follow these three steps
– Compute the 2’s complement of number
– Convert to decimal
– Place a negative sign with answer
Example
Convert signed (1100 1100)2 to decimal equivalent
Solution
As MSB is 1 so number is negative
Step 1:
Compute 2’s complement of (1100 1100)2 which is (00110100)2
Step 2:
Convert the complemented number to decimal
(00110100)2 = (1 x 25) + (1 x 24) + (1 x 22) = 32 + 16 + 4 = (52)10
Step 3:
Place a negative sign with answer
 (1100 1100)2 = (-52)10
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 8
Signed Decimal to Binary Conversion
(1/2)
• If the number is positive
– Convert to binary by using repeated division
method like unsigned numbers
Example
Convert (+25)10 to binary equivalent
Solution
As the number is positive, so we will use
the repeated division method
 (+25)10 = (11001)2
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 9
Signed Decimal to Binary Conversion (2/2)
• If the number is negative
– Convert the magnitude of the number to binary by using correct number
of bits
– Compute the 2’s complement to get the final answer
Example
Convert (-25)10 to binary equivalent
Solution
As the number is negative so we need to follow two steps
Step 1:
Convert the magnitude of (-25) to binary
And we need at least 6 bits to represent (-25)
Zero Appended to Complete 6 bits
(25)10 = (011001)2
Step 2:
Compute the 2’s complement to get the final answer
2’s complement of (011001)In case we have used 5 bits in step 1, the final answer
2 is (100110)2
would be (00110)2, which is obviously incorrect
 (-25)10 = (100110)2
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 10
Arithmetic Addition in Signed Binary
Numbers
• The addition of two signed binary numbers with negative
numbers represented in signed‐ 2’s complement form is obtained
from the addition of the two numbers, including their sign bits
• A carry out of the sign‐bit position is discarded
Example
Compute (+6) + (-13) in binary.
Solution
+ 6 = (00110)2
+13 = (01101)2 (11001)2 = (-7)10 How?
 -13 = (10011)2
+6 = +0 0 1 1 0
-13 = +1 0 0 1 1
-7 = +1 1 0 0 1
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 11
Arithmetic Subtraction in Signed
Binary Numbers
• For subtraction we prefer 2’s complement method
– Take the 2’s complement of the subtrahend (including the sign bit)
and add it to the minuend (including the sign bit)
– A carry out of the sign‐bit position is discarded
Example
Subtract 14 from 26 by using 2’s complement method.
Solution
-26 = (11010)2 Final Answer = (01100) = (+12) 2 10
-14 = (01110)2
 -14 = (10010)2
-26 = + 0 1 1 0 1 0
-14 = + 0 1 0 0 1 0
End Carry Discarded
+12 = + 1 0 1 1 0 0
EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 12
Practice Problem 2
Compute A + B – C by using 2’s complement
method and use 8-bits to represent every
number. In the end verify that your answer is
correct.
A = (72)10 B = (10111110)2 C = (-18)10

Answer is (24)10 = (0001 1000)2

EE227 - DLD Course Instructor : Muhammad Sajid Iqbal 13

You might also like