Professional Documents
Culture Documents
MSC and BSIT Chapter 1 04 - 09 - 2020
MSC and BSIT Chapter 1 04 - 09 - 2020
2
Digital Design
With an Introduction to the Verilog HDL
FIFTH EDITION
By : M. Morris Mano & Michael D. Ciletti
Digital Fundamentals
NINTH EDITION
By : Thomas L. Floyed
3
To familiarize the IT Professionals
about
the internal mechanism and
Operations of the computer
systems
4
Digital Systems
This age is called Digital Age
Digital now a days is a buzz word
We have digital
Telephones
digital televisions
digital versatile discs
digital cameras
handheld devices and
of course, digital computers. 5
Digital Systems
Uses of Digital Technology
Digital systems are used in
spacecraft guidance
medical treatment
weather monitoring
the Internet and
many other commercial, industrial,
and scientific enterprises.
6
Digital Systems
What is digital?
In electronics context Digital
Is a form of signal
More accurately called Digital Signal
Also called Discrete Signal
7
What is Signal?
Generally a signal is
A gesture, action, or sound that is used to
convey information or instructions.
More simply it can be expressed any thing
with which we associate some value or
information and the relevant people are
able to understand that information.
In physics context, it is an electrical
impulse or radio wave transmitted or
received.
8
Types of Signals
9
Types of Signals
Analog or Continuous Signal
Exist in a nature
Exist in a wave form
Examples are
Sound waves
Light waves
Analog Wall Clock or Speedo Meter
10
Types of Signals
Digital or Discrete Signal
Derived Signal
Exist in a form of pulses
11
Types of Signals
Digital or Discrete Signal
Examples are
Digital Speedometer
Digital Watch
12
Numbers Conversion
15
Numbers Conversion
16
Numbers Conversion
Sum of Positional Weight Method
Following are the steps:
First of all mark the position of the digits in the given
value starting with zero from right to left
Then multiply each digit with its base/radix raised to
the power of it’s position in the given value. This will
determine the weight of the each digit in the given
value
Finally add all the weights of each digit in the given
value
Whatever you get it will be the decimal equivalent of
the given value
17
Numbers Conversion
For example
(11010)2 is a binary value, its decimal
equivalent can be found by using Sum of
Positional Weight Method as under:
First mark the position of each digit in the given
value. Start from the right side and with zero.
1413 021100
Calculate the weight of the each digit in the
given value Position of the digit in the
given value
1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20
Base or Radix of the
Digit in the given value given value
18
Numbers Conversion
Finally Sum all the weights of each digit
in the given value, it will give you the
decimal equivalent of the given value
that is:
= (26)10
More accurately can by written as
(11010)2 = (26)10
19
Numbers Conversion
Similarly
(4021)5 is a penta value, its decimal
equivalent can be found by using Sum of
Positional Weight Method as under:
43 02 21 10 Position of the digit
in the given value
4 x 53 + 0 x 52 + 2 x 51 + 1 x 50
= (511)10
Digit in the Base or Radix of
Thus given value the given value
(4021)5 = (511)10
20
Numbers Conversion
Similarly
(56321)8 is an octal value, its decimal
equivalent can be found by using Sum of
Positional Weight Method as under:
54 63 32 21 10 Position of the digit
in the given value
5 x 84 + 6 x 83 + 3 x 82 + 2 x 81 + 1 x 80
= (23761)10
Digit in the Base or Radix of
Thus given value the given value
(56321)8 = (23761)10
21
Numbers Conversion
Similarly
(A6DC0F1)16 is a hexadecimal value,
before finding its decimal equivalent
first we must know
How it has been written?
What does it mean by F, C, D, A
22
Numbers Conversion
Concept of Digit or Symbol and Value
3
iii
٣
All the above mentioned thee numbers represent
the same value but different symbols.
This means different languages use different
symbols to describe the same value.
Furthermore it can also be concluded that
It is not merely symbols which are important but the
concept of values which have been associated with
those symbols.
23
Numbers Conversion
Caveman Number System
The most primitive number system found
written on the walls of caves called
caveman number system.
It has the following 5 symbols
∑, ∆,>, ῼ and ↑
24
Numbers Conversion
Actually hexadecimal number system is Base
16 number system so we need 16 symbols to
represent it. In order to fulfill this
requirement we borrowed symbols or
numbers 0-9 from decimal number system
and the remaining six symbols are borrowed
from alphabets. Thus we can represent the
numbers for hexadecimal as under:
0,1,2,3,4,5,6,7,8,9 and
For 10 = A, 11 = B, 12 = C, 13 = D, 14 = E and 15 = F
25
Numbers Conversion
So now let us learn how to convert a value in
hexadecimal into decimal number system:
(A6DC0F1)16 is a hexadecimal value, its decimal equivalent
can be found by using Sum of Positional Weight Method as
under:
A6 65 D4 C3 02 F1 10
A x 166 + 6 x 165 + D x 164 + C x 163 + 0 x 162 + F x 161 + 1 x 160
10 x 166 + 6 x 165 + 13 x 164 + 12 x 163 + 0 x 162 + 15 x 161 + 1 x 160
167772160 + 6291456 + 851968 + 49152 + 0 + 240 + 1
= (174964977)10
Thus
(A6DC0F1)16 = (174964977)10
26
Numbers Conversion
Now let us do some practice:
Calculate the decimal equivalent of the following
given number:
(11010111)2 = (?)10
(11010111)2 = (215)10
(23041)6 = (?)10
(23041)6 = (3265)10
(72150)7 = (?)10
(72150)7 = (Not Possible)10
(331256)8 = (?)10
(331256)8 = (111278)10
(F10B110CA)16 = (?)10
(F10B110CA)16 = (64704549066)10
27
Numbers Conversion of Fractional Values
(26.46875)10
(11010.01111)2 = (26.46875)10
29
Number Conversion Practice
(Base r to Decimal)
(14215.345)8
(A4210DE.C45B)16
(21251.341)5
(31240.0819)8
30
Numbers Base Conversion
Divide and Remainder Rule or Repeated
Division Rule
Used to convert from decimal number system to any
other number system or base r
The conversion of a decimal integer to a number
in base r is done
by dividing the number and all successive quotients
by r and
accumulating the remainders.
Thisprocedure is best illustrated by
example.
31
Numbers Base Conversion
For example
Conversion of decimal 41 to binary is carried
out as following:
First, 41 is divided by 2 to give an integer
quotient of 20 and a remainder of 1
Then the quotient is again divided by 2 to
give a new quotient and remainder
The process is continued until the integer
quotient becomes 0
32
Numbers Base Conversion
Thencoefficients/answer of the
produced binary number are obtained
from the remainders
33
Numbers Base Conversion
For better understanding this procedure is
explained mathematically as under:
Base r or
number system Given Value
in which to Quotient
2 41
convert
2 20 1
2 10 0
2 5 0 Remainder
2 2 1
1 0
Bottom
Thus up
(41)10 = (101001)2 Approach
34
Numbers Base Conversion
Convert decimal 153 to octal
number system
The required base r is 8 So,
First, 153 is divided by 8 to give an integer
quotient of 19 and a remainder of 1
Then 19 is divided by 8 to give an integer
quotient of 2 and a remainder of 3
Finally, 2 is divided by 8 to give a quotient
of 0 and a remainder of 2.
35
Numbers Base Conversion
Mathematically it can be demonstrated
as:
Base r or Given Value
number system
in which to Quotient
convert 8 153
8 19 1
2 3
Remainder
Thus Bottom
up
(153)10 = (231)8 Approach
36
Numbers Base Conversion
Convert decimal (137532)10 to
hexadecimal number system
The required base r is 16 So,
First, (137532)10 is divided by 16 to give an integer
quotient of 8595 and a remainder of 12 which is
equal to C in hexadecimal
Then 8595 is divided by 16 to give an integer
quotient of 537 and a remainder of 3
Then 537 is divided by 16 to give an integer
quotient of 33 and a remainder of 9
Finally, 33 is divided by 16 to give a quotient of 2
and a remainder of 1.
37
Numbers Base Conversion
Mathematically it can be demonstrated
as:
Base r or Given Value
number system
in which to Quotient
convert 16 137532
16 8595 12 = C
16 537 3
Remainder
16 33 9
2 1
Thus Bottom
up
(137532)10 = (2193C)16 Approach
38
Number Conversion Practice
for Divide & Remainder Rule
(174)10 = (?)2
(534)10 = (?)8
(50342)10 = (?)16
39
Numbers Base Conversion
Fractional Number Conversion by using
repeated multiplication method
Convert (0.6875)10 to binary.
First, 0.6875 is multiplied by 2 to give an
integer and a fraction.
Then the new fraction is multiplied by 2 to
give a new integer and a new fraction.
The process is continued until the fraction
becomes 0 or until the number of digits has
sufficient accuracy.
40
Numbers Base Conversion
Thecoefficients of the binary number
are obtained from the integers as
follows:
0.6875 x 2= 1.3750 a-1 = 1
0.3750 x 2= 0.7500 a-2 = 0 Top down
0.7500 x 2= 1.5000 a-3 = 1 Approach
43
Numbers Base Conversion
So this value will be solved in two parts:
For non-fractional part we will apply divide & remainder rule
or repeated division rule as under:
Base r
or Given Value
number Quotient
system 2 41
in
2 20 1
which
to 2 10 0
convert Remainder
2 5 0
2 2 1
1 0
Thus Bottom
up
(41)10 = (101001)2 Approac
h
44
Numbers Base Conversion
Whereasfor fractional part we will apply
repeated multiplication rule as under:
0.6875 x 2 = 1.3750 a = 1-1
46
Number Conversion Practice
from Decimal to Base r
(10101011.0123)10 = (?)8, 6
(145110.3456)10 = (?)8, 16
47
Numbers Base Conversion
Until now we were dealing with
number conversions:
From Base r (2, 8,16 etc.) to Decimal
Number System OR
From Decimal Number System to any other
Base r (2, 8,16 etc.)
In both above mentioned cases, it is
obvious that Base 10 is always present
either on right side of the equation or on
left side of the equation.
48
Numbers Base Conversion
What about if we are to convert from
any Base r to any Base other than
Decimal Number (Base 10) or vice
versa?
In such cases we will adopt the two
steps solution
49
Numbers Base Conversion
InStep 1 we will first convert that given
value in base r to decimal base by using
Sum of Positional Weight method and
InStep 2 we will convert the obtained
value (which will be in Base 10) into the
desired base r by using Divide and
Remainder Rule.
Itcan be best explained by the following
example:
50
Numbers Base Conversion
Convert (4021)5 to Octal Number
System
In this case the direct conversion from
Penta Number System to Octal Number
System is not possible.
We first have to convert from Base 5 to
Base 10 by using Sum of Positional
Weight Method as following:
51
Numbers Conversion
First we mark the position of the digits in the
given value
43 02 21 10
Next we calculate the weights of the digits in the given
value Position of the digit in
the given value
4 x 53 + 0 x 52 + 2 x 51 + 1 x 50
= (511)10
Digit in the Base or Radix of
Thus the given value
given value
(4021)5 = (511)10
Now we will convert this obtained value in
Decimal Number System into Octal by using Divide
& Remainder Rule as following:
52
Numbers Base Conversion
Mathematically it can be demonstrated as:
Base r or
number system Given Value
in which to Quotient
convert 8 511
8 63 7
7 7
Remainder
Bottom
Thus up
Approach
(511)10 = (777)8 So, we can write
(4021)5 = (777)8
53
Numbers Base Conversion
Number Conversion Practice
Convert (234)4 to Base 7
Convert (2012.121)3 to Base 8
54
Numbers Base Conversion
ShortCut Method for Conversion from
Binary to Octal or Hexadecimal or vice
versa.
The conversion from and to binary, octal,
and hexadecimal plays an important role
in digital computers, because shorter
patterns of hex characters are easier to
recognize than long patterns of 1’s and
0’s.
55
Numbers Base Conversion
Since 23 = 8 , it means three digits of
binary can produce one digit of Octal and
vice versa.
For example to convert
(111 110 001 101 011)2 = (?)8
Aswe know that 23 = 8 so we make the
groups of given binary value such that
each group contains three bits. For this
purpose we will start making groups from
the right side and move towards left side
as mentioned in the following slide
56
Numbers Base Conversion
(111 110 001 101 011)2
Next we convert each group of binary
into its Octal equivalent as following:
(111 110 001 101 011)2
7 6 1 5 3
It means
(110 110 001 101 011)2 = (76153)8
57
Numbers Base Conversion
But what about if it is given like this:
(1 011 101 111 010)2
In this case we will again make a group of
three starting from the right and if at the
end there are less than three digits are
left for the group then
we will complete the number of digits in
the group by packing zero(s) on the left
side of the digit as following:
58
Numbers Base Conversion
(001 011 101 111 010)2
1 3 5 7 2
It means
(001 011 101 111 010)2= (13572)8
59
Numbers Base Conversion
In case of fractional values we will do the same with a
little bit difference
As you know fractional values may contain Non-Fractional Part
as well as Fractional Part. Thus the difference lies in group
making and zero(s) packing.
In case of values which contain both part, for the Non-
Fractional Part we make group of three digits starting from the
right and move towards left and if at the end less than three
digits are left then we will pack zero(s) on the left side to
complete the group.
Whereas for Fractional Part we start making groups from the
left and move towards right and if at the end less than three
digits are left then we will complete the group by packing with
zero(s) on the right side to complete the group.
60
Numbers Base Conversion
It can best be explained with the following example:
Convert (110 011 001 100 010.101 111 110)2 to Octal
To convert it by using short cut method, we will proceed as following:
Make groups for Non Fractional as well as for Fractional Part as told
before, we will get: Move Left Move Right
6 3 1 4 2. 5 7 6
It means
(110 011 001 100 010.101 111 110)2 = (63142.576)8
61
Numbers Base Conversion
Now look at another example in which
digits in the last group(s) are less than
three.
Convert (1 011 101 111 110.011 110 1)2 to
Octal
To convert it by using short cut method, we
will proceed as following:
Make groups for Non Fractional as well as for
Fractional Part as told before, we will get:
62
Numbers Base Conversion
(1 011 101 111 110.011 110 1)2
As you can see in each part (Non-Fractional as well as Fractional)
there is one incomplete group, so to complete them we will pack
zero(s) as following:
Move Left Move Right
1 3 5 7 6. 3 6 4
It means
(001 011 101 111 110.011 110 100)2 = (13576.364)8
63
Numbers Base Conversion
Similarlyif we are to convert from
Octal to Binary then
As we know 23 = 8,
It means each digit of Octal will
produce 3 digits of binary.
For example to convert (35061.247)8 to
Binary we will proceed as following:
64
Numbers Base Conversion
(3 5 0 6 1 . 2 4 7)8
It means
(35061.247)8= (011 101 000 110 001 . 010 100 111)2
65
Numbers Base Conversion
9 12 6 11
9 C 6 B
It means
(1001 1100 0110 1011)2 = (9C6B)16
69
Numbers Base Conversion
Incase of fractional value, for example
(1010 1100 0110 1011 .1111 0010)2
We will proceed as following:
(1010 1100 0110 1011 .1111 0010)2
10 12 6 11 . 15 2
2 C 6 B . F 2
It means
(1010 1100 0110 1011 .1111 0010)2 = (2C6B.F2)16 70
Numbers Base Conversion
In case if we have incomplete groups at both
ends, for example
(101 0000 0110 1111 .1100 1)2
We will proceed as told before in case of Octal:
(0101 0000 0110 1111 .1100 1000)2
5 0 6 15 . 12 8
5 0 6 F . C 8
It means
(101 0000 0110 1111 .1100 1)2 = (5 0 6 F . C 8)16 71
Numbers Base Conversion
Similarlyif we are to convert from
Hexadecimal to Binary then
As we know 24 = 16,
It means each digit of Hexadecimal
will produce 4 digits of binary.
For example to convert (320CA.D4F)16
to Binary we will proceed as following:
72
Numbers Base Conversion
(3 2 0 C A . D 4 F)16
It means
(320CA.D4F)16 = (0011 0010 0000 1100 1010 . 1001 0100 1111)2
73
Complements of a Numbers
Complements are used in digital
computers to
simplify the subtraction operation and
For logical manipulation.
Simplifying operations leads to
Simpler circuits and
less expensive circuits to implement the
operations.
74
Types of Complements
There are two types of complements for
each base‐r system:
The Radix Complement also referred as
the r’s complement
The Diminished Radix Complement also
known as
the (r - 1)’s complement.
Where “ r ” refers to any base e.g. 2, 5,8,
10 etc. 75
Types of Complements
If the value of r is substituted in the
name for binary numbers then
two
types are referred to as the 2’s
complement and 1’s complement and
If the value of r is substituted in the
name for decimal numbers then
The
two types are called 10’s
complement and 9’s complement
76
How to Determine Radix or r’s
Complement for Decimal Numbers
The formula to determine r’s
Complement is:
rn – N where
r is any base or number system
N is given value and
n is number of digits in the given value
77
How to Determine Radix or r’s
Complement for Decimal Numbers
Let us suppose we are given the
following value to determine its r’s
complement
(786532)10
As we know rn – N where
r is any base and in this case is equal to 10
N is given value and in this case is equal to
786532
n is the number of digits in the given value which
are in this case equal to 6 78
How to Determine Radix or r’s
Complement for Decimal Numbers
Now by putting the values in the
formula r – N , we have:
n
106 – 786532 or
1000000 – 786532 and
= 213468 which is the r’s complement of
the given value
As in this case the base or radix (r) is 10,
so we can also call it 10’s Complement 79
How to Determine Diminished
Radix or r- 1’s Complement for
Decimal Numbers
The formula to determine r-1’s
Complement is:
(rn – 1) - N where
r is any base or number system
N is given value and
n is number of digits in the given value
80
How to Determine Diminished
Radix or r- 1’s Complement for
Decimal Numbers
Let us suppose we are given the same
value to determine its r-1’s complement
(786532)10
As we know Diminished Radix Complement =
(rn – 1) - N where
r is any base and in this case is equal to 10
N is given value and in this case is equal to 786532
n is the number of digits in the given value which are
in this case equal to 6 81
How to Determine Diminished
Radix or r- 1’s Complement for
Decimal Numbers
Now by putting the values in the formula
(rn – 1) - N , we have:
(106 – 1) - 786532 or
(1000000 – 1) – 786532
999999 - 786532
= 213467 which is the r - 1’s complement of the
given value
As in this case the base or radix (r) is 10, and r-1
= 9 so we can also call it 9’s Complement
82
How to Determine Diminished
Radix or r- 1’s Complement for
Decimal Numbers
Also note that there is only a difference of
1 in r’s and r-1’s complement
It means if we know r’s complement, we
can determine r-1’s complement simply by
subtracting 1 from the given value and
vice versa
83
Practice Exercise for Determining
r’s and r-1’s Complement for
Decimal Numbers
Find the r’s and r-1’s Complement for the
following:
9966332
7625345
88976543
12345678
84
How to Determine Radix or r’s
Complement for Binary Numbers
The formula to determine r’s
complement of Binary Numbers is
the same i.e.
rn – N where
r is any base or number system
N is given value and
n is number of digits in the given value
85
How to Determine Radix or r’s
Complement for Binary Numbers
Let us suppose we are given the
following value to determine its r’s
complement
(111011)2
As we know Radix Complement = rn – N where
r is any base and in this case is equal to 2
N is given value and in this case is equal to
111011
n is the number of digits in the given value which
are in this case equal to 6 86
How to Determine Radix or r’s
Complement for Binary Numbers
Now by putting the values in the
formula r – N , we have:
n
26 – 111011 or
1000000 – 111011 and
= 000101 which is the r’s complement of
the given value
As in this case the base or radix (r) is 2, so
we can also call it 2’s Complement 87
How to Determine Diminished
Radix or r- 1’s Complement for
Binary Numbers
The formula to determine r-1’s
Complement for Binary Numbers is
also the same i.e.
(rn – 1) - N where
r is any base or number system
N is given value and
n is number of digits in the given value
88
How to Determine Diminished
Radix or r- 1’s Complement for
Binary Numbers
Let us suppose we are given the same
value to determine its r-1’s complement
(111011)2
As we know Diminished Radix Complement =
(rn – 1) - N where
r is any base and in this case is equal to 2
N is given value and in this case is equal to 111011
n is the number of digits in the given value which are
in this case equal to 6 89
How to Determine Diminished
Radix or r- 1’s Complement for
Binary Numbers
Now by putting the values in the formula
(rn – 1) - N , we have:
(26 – 1) - 111011 or
(1000000 – 1) – 111011
111111 – 111011
= 000100 which is the r - 1’s complement of the
given value
As in this case the base or radix (r) is 2, and r-1 =
1 so we can also call it 1’s Complement
90
How to Determine Diminished
Radix or r- 1’s Complement for
Binary Numbers
Also note that there is only a difference of
1 in r’s and r-1’s complement
It means if we know r’s complement, we
can determine r-1’s complement simply by
subtracting 1 from the given value and
vice versa
91
Short Cut Method to Determine
Diminished Radix or r- 1’s
Complement for Binary Numbers
As we know Binary Numbers contain only two digits i.e.
1 or 0.
Hence when subtracting binary digits from 1, we can have either
1 - 0 = 1 or
1-1=0
which causes the bit to change from 0 to 1 or from 1 to 0,
respectively.
Therefore, the 1’s complement of a binary number is
formed by:
changing 1’s to 0’s and 0’s to 1’s.
92
Short Cut Method to Determine
Diminished Radix or r- 1’s
Complement for Binary Numbers
For example the 1’s complement of 1011000
is obtained as under:
We start scanning or reading given value from the right
side and revert each 0 to 1 and each 1 to 0. For better
clarification look at the following:
Given Value: 1011000
1’s Complement: 0100111
Similarly
Given Value: 0101101
1’s complement: 1010010 93
Short Cut Method to Determine
Radix or r’s or 2’s Complement for
Binary Numbers
The same method can be applied to determine the
r’s Complement of the given Binary Number with a
little bit difference.
In this case we also start scanning or reading value from the
right side
But we don’t start reverting the value until we met first 1
from the right in the given value
This first 1 and all the 0s before this 1 will not be reverted
and kept as it is
But all the digits after this first 1 will be reverted as we did in
case of r-1’s Complement.
94
Short Cut Method to Determine
Radix or r’s or 2’s Complement of
Binary Numbers
For example the 2’s complement of
1011000 is obtained as under:
Given Value: 1011000
2’s Complement: 0111000
Similarly
Given Value: 0101101
2’s complement: 1010011
95
Third Method to Determine r’s or
2’s & r-1’s or 1’s Complement of
Binary Numbers
As
we know there is only a difference of 1
between r’s and r-1’s complement. So
If we have 1’s complement then
we can determine 2’s complement by
simply adding 1 into the 1’s complement of
the given value.
96
Third Method to Determine r’s or
2’s & r-1’s or 1’s Complement of
Binary Numbers
For example: Find the 1’s & 2’s complement for
1111010101.
Now the given value = 1111010101
1’s complement of the given value = 0000101010
For 2’s complement:
1’s complement of the given value = 0000101010
To determine 2’s complement adding 1 = +1
So the 2’s complement of the given value = 0000101011
97
Third Method to Determine r’s or
2’s & r-1’s or 1’s Complement of
Binary Numbers
Similarly
Ifwe have 2’s complement then we can
determine 1’s complement by simply
subtracting 1 from the 2’s complement of the
given value
So we take the same previous given value and
determine the 1’s complement
98
Third Method to Determine r’s or
2’s & r-1’s or 1’s Complement of
Binary Numbers
For example: Find the 2’s & 1’s complement for
1111010101.
Now the given value = 1111010101
2’s complement of the given value = 0000101011
For 1’s complement:
2’s complement of the given value = 0000101011
To determine 1’s complement subtracting 1 = -1
So the 1’s complement of the given value = 0000101010
99
Subtraction with Complements
for Decimal Numbers
As you are told computer performs subtraction
in the way of addition by using complement.
How does computer do this?
Following are the steps to perform subtraction in
the way of addition
First: Identify the minuend and subtrahend in the
given value
Second: Equate the number of digits in the given
operands by packing zero(s) on the left
for the operand having less number of digits than the other
operand
100
Third: Take the complement of the subtrahend
Subtraction with Complements
for Decimal Numbers
Fourth: Add the complement of the subtrahend
into the minuend
Fifth: As a consequence of fourth step you will
get the Sum
Sixth: Before writing the answer, we will first
consider the following:
After performing fourth step if the number of digits
in the Sum are more than the number of digits in the
minuend or subtrahend’s value then
The extra digit will be considered as a carry
We simply discard the carry and
Whatever left will be our answer
101
Subtraction with Complements
for Decimal Numbers
However, after performing the fourth step if the
number of digits in the Sum are equal to the
number of digits in the minuend or subtrahend’s
value then
We will take the complement of the Sum
After taking complement we will place negative
sign in front of the complemented value and
Write it as our answer
102
Subtraction with Complements
for Decimal Numbers
While
performing subtraction with the help of
complement one should also keep in mind:
If the number of digits in the SUM are more than
the number of digits in the minuend or
subtrahend then it will mean that:
Minuend is greater than the Subtrahend and
Obtained Sum is positive or
We can also say that
if Minuend ≥ Subtrahend then sum will always produce
an end carry, which can be discarded; what is left is
the result with positive sign
103
Subtraction with Complements
for Decimal Numbers
Similarly
If the number of digits in the SUM are equal to the
number of digits in the minuend or subtrahend then it
will mean that:
Minuend is smaller than the Subtrahend and
Obtained Sum is negative or
We can also say that
if Minuend < Subtrahend
then sum will not produce an end carry and
In this case to obtain the answer in a familiar form,
take the r’s complement of the sum and place a
negative sign in front. 104
Subtraction with Complements
for Decimal Numbers
The following examples illustrate the procedure:
Q: Using 10’s complement, subtract 72532 - 3250.
In order to perform this subtraction we will
follow the steps outlined in the previous slides
i.e.
First: Identify the minuend and subtrahend in the
given value
In this case:
Minuend (M) = 72532 and Subtrahend (N) = 3250
Second: Equate the number of digits in the given
operands by packing zero(s) on the left i.e.
Minuend (M) = 72532 and Subtrahend (N) = 03250 105
Subtraction with Complements
for Decimal Numbers
Third: Take the complement of the subtrahend
In this case Subtrahend (N) = 03250 and
Complement of N = 96750
Fourth: Add the complement of the subtrahend
into the minuend this will produce the Sum
M= 72532
10’s complement of N = + 96750
Sum = 169282
To discard end carry 105 = - 100000
Answer = 69282
106
Subtraction with Complements
for Decimal Numbers
Fifth:Remember, Before writing the answer,
we will first consider the following:
After performing fourth step if the number of
digits in the Sum are more than the number of
digits in the minuend or subtrahend’s value then
The extra digit will be considered as a carry
We simply discard the carry and
Whatever left will be our answer with positive
value i.e.
Answer = 69282 107
Subtraction with Complements
for Decimal Numbers
Let us consider another example to illustrate the case
in which No Carry Produce.
Q: Using 10’s complement, subtract 3250 - 72532.
In order to perform this subtraction we will again
follow the steps outlined in the previous slides i.e.
First: Identify the minuend and subtrahend in the given
value
In this case:
Minuend (M) = 3250 and Subtrahend (N) = 72532
Second: Equate the number of digits in the given operands by
packing zero(s) on the left i.e.
Minuend (M) = 03250 and Subtrahend (N) = 72532
108
Subtraction with Complements
for Decimal Numbers
Third: Take the complement of the subtrahend
In this case Subtrahend (N) = 72532 and
Complement of N = 27468
Fourth: Add the complement of the subtrahend into the
minuend, this will produce the Sum
M = 03250
10’s complement of N = + 27468
Sum = 30718
As no carry is generated, So take r’s complement of the
Sum which is 69282
Now write the answer by placing negative sign in front of
the Sum
Answer = - 69282 109
Subtraction with Complements
for Decimal Numbers
Fifth:Remember, Before writing the answer,
we will first consider the following:
After performing fourth step if the number of
digits in the Sum are equal to the number of
digits in the minuend or subtrahend’s value then
There is no end carry generated, so in this case
the answer will be obtained by taking the
complement of the Sum and
By placing negative sign in front of the answer
i.e.
Answer = -69282 110
Subtraction with Complements
for Binary Numbers
Allthe steps to perform subtraction with
decimal numbers are also applicable to
perform subtraction with binary number
For example: Given the two binary numbers
X = 1010100 and Y = 1000011
perform the subtraction
i) X – Y and
ii) Y-X
111
Subtraction with Complements for
Binary Numbers
Case-1: X – Y
In this case
Minuend = X = 1010100 and
Subtrahend = Y = 1000011
2’s Complement of Subtrahend = Y = 0111101
Now , X = 1010100
Adding 2’s complement of Y = + 0111101
Sum = 10010001
Discard end carry 27 = - 10000000
Answer: X - Y = 0010001
112
Subtraction with Complements for
Binary Numbers
Case-2: Y – X
In this case
Minuend = Y = 1000011 and
Subtrahend = X = 1010100
2’s Complement of Subtrahend = X = 0101100
Now , Y = 1000011
Adding 2’s complement of X = + 0101100
Sum = 1101111
As no carry produced therefore
Taking 2’s complement of the Sum = 0010001
Answer: Y – X = - (0010001)
113
Practice Assignment for
Subtraction with Complement
Find A – B & B – A for the following
given decimal & binary values:
1. A = 34567 & B = 737266
2. A = 2233445 & B = 7299
3. A = 1010101 & B = 11111111
4. A = 10111111 & B = 10000
5. A = 11011011 & B = 111000
114
SIGNED BINARY NUMBERS
It is common observation that:
Positive integers (including zero) can be
represented as unsigned numbers.
However, to represent negative
integers, we need
a notation for negative values.
In ordinary arithmetic,
a negative number is indicated by a minus
sign and
a positive number by a plus sign. 115
SIGNED BINARY NUMBERS
As we know because of hardware limitations,
computers must represent everything with binary
digits.
It is common observation that:
Positive integers (including zero) can be represented as ,
unsigned numbers e.g. 1, 4, 10 or
As signed numbers e.g. +1, +2, +4, +10 etc.
However, we must need a notation to represent negative
integers e.g. -1, -4, -10 etc.
That’s why in ordinary arithmetic,
a negative number is indicated by a minus sign and
a positive number, may or may not be,by a plus sign. 116
SIGNED BINARY NUMBERS
As we know because of hardware limitations,
computers must represent everything with
binary digits.
It is customary to represent the sign with a
bit placed in the leftmost position of the
number. The convention is to make the sign
bit 0 for positive and 1 for negative.
117
SIGNED BINARY NUMBERS
It is important to realize that both
signed and unsigned binary numbers consist of a
string of bits when represented in a computer.
Theuser determines whether the number is
signed or unsigned.
If the binary number is signed, then
the leftmost bit represents the sign and the rest of
the bits represent the number or magnitude
118
SIGNED BINARY NUMBERS
Ifthe binary number is assumed to be
unsigned, then
the leftmost bit is the most significant bit of the
number.
Forexample, the string of bits 01001 can be
considered
as 9 (unsigned binary) or
as +9 (signed binary)
because the leftmost bit is 0. 119
SIGNED BINARY NUMBERS
Similarly,the string of bits 11001 represents
the binary equivalent of 25
when considered as an unsigned number and
the binary equivalent of -9
when considered as a signed number.
This is because the 1 that is in the leftmost
position designates
a negative and the other four bits represent
binary 9 or magnitude of 9 120
SIGNED BINARY NUMBERS
121
SIGNED BINARY NUMBERS
In signed‐magnitude representation
The left most bit is considered as sign bit
If this bit represents 0 then its sign will be considered
positive and value is +ve
If this bit represents 1 then its sign will be considered
negative and value is _ve.
For example: 00001001 which is actually 8-
bit binary/magnitude of 9, if considered as
signed value then
00001001 represents +9
10001001 represents -9
122
SIGNED BINARY NUMBERS
Also in signed‐1’s‐complement representation
The left most bit is considered as sign bit
If this bit represents 0 then its sign will be considered
positive and value is +ve
If this bit represents 1 then its sign will be considered
negative and value is _ve.
For example: 00001001 which is actually 8-bit
binary/magnitude of 9, if considered as signed
value then
00001001 represents +9
11110110 represents -9
123
SIGNED BINARY NUMBERS
Also in signed‐2’s‐complement representation
The left most bit is considered as sign bit
If this bit represents 0 then its sign will be considered
positive and value is +ve
If this bit represents 1 then its sign will be considered
negative and value is _ve.
For example: 00001001 which is actually 8-bit
binary/magnitude of 9, if considered as signed
value then
00001001 represents +9
11110111 represents -9
124
SIGNED BINARY NUMBERS
Find the decimal equivalent for
the following signed values under
the 3-representation schemes:
10100010
11010011
11110111
00100010
01110111
125
Arithmetic Addition of
Signed Numbers
Carry
Generated
+ 6 00000110 - 6 111111010
+ 13 00001101 + 13 00001101
+ 19 00010011 + 7 100000111 Carry
Discarded
Carry
+ 6 00000110 - 6 111111010 Generated
- 13 11110011 - 13 11110011
- 7 11111001 - 19 111101101
Carry
Discarded
126
Arithmetic Addition of
Signed Numbers
Note that
negative numbers must be initially in
2’s‐complement form and that
if the sum obtained after the addition is
negative, it is in 2’s‐complement form.
For example
-7 is represented as 11111001
which is the 2’s complement of +7.
127
Arithmetic Addition of
Signed Numbers
In each of the four cases, the
operation performed is addition
with the sign bit included.
Any carry out of the sign‐bit
position is discarded, and
Negative results are automatically
in 2’s‐complement form
128
Arithmetic Addition of
Signed Numbers
The complement form of representing negative numbers is
unfamiliar to those used to the signed‐magnitude system.
To determine the value of a negative number in signed‐2’s
complement, it is necessary to convert the number to a
positive number to place it in a more familiar form.
For example, the signed binary number 11111001 is
negative because the leftmost bit is 1. Its 2’s complement
is 00000111, which is the binary equivalent of +7.
We therefore recognize the original negative number to be
equal to -7.
129
Arithmetic Addition of
Signed Numbers
It is worth noting that binary numbers in the
signed‐complement system are added and subtracted by
the same basic addition and subtraction rules as unsigned
numbers.
Therefore, computers need only one common hardware
circuit to handle both types of arithmetic.
This consideration has resulted in the signed‐complement
system being used in virtually all arithmetic units of
computer systems.
The user or programmer must interpret the results of such
addition or subtraction differently, depending on whether
it is assumed that the numbers are signed or unsigned.
130