DLD - Lecture3 (Completed)
DLD - Lecture3 (Completed)
ECE2002
Reference Books:
1. Mandal ”Digital Electronics Principles & Application, McGraw Hill
Edu,2013.
2. Comer “Digital Logic & State Machine Design, Oxford, 2012.
3. William Keitz, Digital Electronics-A Practical Approach with
VHDL,Pearson,2013
Unit:1
Digital Logic
Design
Fundamentals
Topic: Complement
Binary Multiplication/Division
Octal Arithmetic
3 2 7. 5 4 20.14
+ 6 6 5. 3 7 - 16.47
1 2 1 5. 1 3 0 1. 4 5
Complements of Numbers
• We take complement to represent negative number because the computer cannot
perform subtraction directly
• We can perform (r-1)’s complement or r’s complement to represent the negative
number, where r=radix is base of the number system (e.g : 10 for decimal , 8 for
octal, 16 for hexadecimal and 2 for binary)
(r-1)’s complement
•Calculate :
•9’s complement of 546700, 12398
•1’s complement of 1011000, 0101101
r’s complement
Step 1: Equate the number of digits if the two numbers are not equal
3250 => 03250
10’s Complement of 03250 = 99999-03250 = 96749+1=96750
Step 2: Add both the number
72532
+96750
169282 Step 3: Ignore carry
Ans : 69282
Subtraction with Complement
Compute (M-N)
N=72532, M=3250
by 10’s complement & 9’s Complement
9’s complement method:
Step 1: Equate the number of digits if the two numbers are not equal
9’s Complement of 72532 = 99999-72532 = 27467
Step 2: Add both the number
03250
+27467
30717 Step 3: No carry do the 9’s complement of the result and put negative
sign
9’s Complement of 30717 = 99999-30717 = 69282
Ans : -69282
Subtraction with Complement
Compute (M-N)
N=72532, M=3250
by 10’s complement & 9’s Complement
10’s complement method:
Step 1: Equate the number of digits if the two numbers are not equal
10’s Complement of 72532 = 99999-72532 = 27467+1 = 27468
Step 2: Add both the number
03250
+27468
30718 Step 3: No carry do the 10’s complement of the result and put negative
sign
10’s Complement of 30718 = 99999-30718 = 69281+1=69282
Ans : -69282
For both positive
Binary Number System and Negative
Numbers
Only for positive Binary Number
System Signed Number
Numbers
Representation
Unsigned Number
Representation
Sign Magnitude Form 2’s Complement Form
1’s Complement Form
Unsigned numbers are by definition
positive numbers and thus do not
require an arithmetic sign. An 𝒏-bit Signed numbers, on the other hand, require an
unsigned number represents all arithmetic sign. The most significant bit of a binary
numbers in the range 0 to 𝟐^𝒏−𝟏. EX: number is used to represent the sign bit. If the sign bit
The range of 8 bit unsigned binary is equal to zero, the signed binary number is positive;
numbers is from 0 to 255 in decimal, otherwise, it is negative. The remaining bits represent
00 to FF in hexadecimal. the actual number.
If an bit binary number is signed the leftmost bit is
used to represent the sign leaving bits to represent the
number.
Sign Magnitude Form
In this approach, a number's sign is represented with a sign bit: setting that bit (often the most significant bit) to 0
for a positive number or positive zero, and setting it to 1 for a negative number or negative zero. The remaining
bits in the number indicate the magnitude (or absolute value).
Ex:
(+3) = 0011 (-3) = 1011
(+7) = 0111 (-7) = 1111
(+0) = 0000 (-0) = 1000
1’s Complement Form 1‘s
The ones' complement form of a negative binary Binary Unsigned
complement
value interpretation
number is the bitwise NOT applied to it, i.e. the interpretation
"complement" of its positive counterpart. 00000000 +0 0
00000001 1 1
1‘s complement also has two representations of 0:
⋮ ⋮ ⋮
00000000 (+0) and 11111111 (−0) 01111101 125 125
The range of signed numbers using ones' complement 01111110 126 126
is represented by to and . 01111111 127 127
10000000 −127 128
A conventional 8-bit byte is to with zero being either 10000001 −126 129
or .
10000010 −125 130
⋮ ⋮ ⋮
11111101 −2 253
11111110 −1 254
11111111 −0 255
ECE2002-Dr.Anirban Bhowmick
Binary Signed Arithmetic
Add (-25) to (-18) in 2’s and 1’s complement with 8 bit register
Solution:
1’s complement:
As this is signed binary number, we will use 0 to represent positive and 1 to
represent
negative in sign bit.
In 1’s complement arithmetic, we will represent negative number in 1’s
complement
form
sign magnitude representation in 8 bit = 1 0011001 Sign Magnitude
in 1’s complement = 11100110 (fix sign bit and flip magnitude bit)
sign magnitude representation in 8 bit = 1 0010010 Sign Magnitude
in 1’s complement = 11101101 (fix sign bit and flip magnitude bit)
Binary Signed Arithmetic
Add both the number = 11100110
11101101
----------------
111010011 Add carry to
+ 1 LSB
-----------------
11010100
Result is negative so we will take 1’s complement of the result to find the magnitude and put a
negative sign
ECE2002-Dr.Anirban Bhowmick
Binary Signed Arithmetic
Add (-25) to (-18) in 2’s and 1’s complement with 8 bit register
Solution:
2’s complement:
As this is signed binary number, we will use 0 to represent positive and 1 to
represent
negative in sign bit.
In 2’s complement arithmetic, we will represent negative number in 2’s
complement
form
sign magnitude representation in 8 bit = 1 0011001 Sign Magnitude
in 2’s complement = 11100111 (fix sign bit and flip magnitude bit and add 1)
sign magnitude representation in 8 bit = 1 0010010 Sign Magnitude
in 1’s complement = 11101110 (fix sign bit and flip magnitude bit and add 1)
Binary Signed Arithmetic
Add both the number = 11100111
11101110
----------------
111010101 Ignore carry
-----------------
11010101
Result is negative so we will take 2’s complement of the result to find the magnitude and put a
negative sign