0% found this document useful (0 votes)
10 views40 pages

UNIT - 1 Introduction

Uploaded by

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

UNIT - 1 Introduction

Uploaded by

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

DIGITAL ELECTRONICS

1 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

1. Introduction

Digital electronics is a type of electronics that deals with the digital systems which
processes the data/information in the form of binary(0s and 1s) numbers, whereas analog
electronics deals with the analog systems which processes the data/information in the form
of continuous signals.

What is an Analog Signal?

Analog communication is a type of communication where the data that is being


communicated is continuous.

It can be explained by an example of radio communication. If communication is happening


with the help of radio waves, analog communication would mean that the frequency and
wavelength of the radio wave at any point of communication can have any value between
the maximum and minimum range.

An example of such communication is if the data to be communicated is the human voice.


The human voice consists of a different range of wavelengths and frequencies. Thus, analog
communication is more dense and complex since it is able to transfer a lot of different
values of data.

The below image is that of an analog signal where the value of the quantity being measured
or transmitted has continuous values as time changes. The values can range between the
maximum and the minimum amplitude.

Examples of Analog Signals

Some common examples of analog signals include:

o Human voice

o Analog Radio and TV Broadcast

o Audio signals transferred via cables

2 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

o Radio signals

o Analog timepieces

Advantages of Analog Signals

Some important advantages are as follows:

o Processing analog signals can be straightforward, especially in scenarios not


requiring complex digital manipulation.

o Analog signals provide seamless transitions, ideal for applications with gradual
variations.

o Analog signals avoid errors introduced during analog-to-digital conversion.

o They exhibit lower delay, crucial for real-time applications.

o Analog signals enable real-time feedback and control.

o They work well with older equipment and systems.

o Analog signals interpolate naturally between values

Disadvantages of Analog Signals

Analog signals have some disadvantages too. These include:

o Analog signals are prone to interference and noise, leading to signal degradation and
inaccuracies.

o They lack robust error correction mechanisms.

o Analog signals weaken and degrade as they travel over long distances due to
attenuation.

o Analog signals can suffer from quantization errors when digitized for storage or
processing.

o Analog signals may not easily integrate with digital systems, leading to compatibility
issues.

o Storing or transmitting analog data efficiently without loss can be more complex than
with digital data.

3 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

What is a Digital Signal?

Digital communication is a type of communication where the data is communicated in the


form of discrete data.

Digital communication is mostly done in computers, where the data to be transferred is in


the form of discrete values. Mostly the data is transferred in the form of binary which has
only two discrete values which are zero and one.

As seen in the above image a digital signal can have only discrete fixed values with
changing time. In this image, the discrete values are 0 V and 5 V.

Examples of Digital Signals

Some common examples include:

o Digital Audio

o Digital Video

o Binary Data

o Digital Clocks

o Smart phones

Advantages of Digital Signals

Some important advantages are as follows:

o Digital signals can incorporate error-checking codes.

o Digital signals are less susceptible to noise and interference.

o They can be regenerated without loss of quality.

4 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

o Digital data can be compressed efficiently without significant loss of information.

o Digital data can be easily manipulated, edited, and transformed using various
algorithms.

o Digital signals can be modulated into analog signals for transmission over analog
channels.

Disadvantages of Digital Signals

Some disadvantages of digital signals include:

o Converting analog signals to digital requires analog-to-digital converters (ADCs),


which can introduce quantization errors

o Improperly sampled or under sampled signals can lead to aliasing, causing distortion
in the reconstructed signal.

o Digital signal processing can require significant computational resources.

o Transmitting digital signals can require higher bandwidth compared to analog signals
for the same information content.

o Implementing digital systems often involves higher initial costs for hardware,
software, and infrastructure.

o Discrete nature of digital signals can lead to loss of fine details present in continuous
analog signals.

A Number system

can be considered as a mathematical notation of numbers using a set of digits or symbols. In


simpler words the number system is a method of representing numbers. Every number
system is identified with the help of its base or radix.

A number system is defined as a system of writing to express numbers. It is the


mathematical notation for representing numbers of a given set by using digits or other
symbols in a consistent manner. It also allows us to operate arithmetic operations like
addition, subtraction, multiplication and division.

The value of any digit in a number can be determined by:

 The digit

5 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

 Its position in the number

 The base of the number system

Base or Radix of a Number System:

The base or radix of a number system can be referred as the total number of different
symbols which can be used in a particular number system. Radix means ―root‖ in Latin.
Base equals to 4 implies there are 4 different symbols in that number system. Similarly,
base equals to ―x‖ implies there are ―x‖ different symbols in that number system.

Classification of Number System:

The number system can be classified in to two types namely:

Positional and Non-Positional number system

1. Positional (or Weighted) Number System:

A positional number system is also known as weighted number system. As the name
implies there will be a weight associated with each digit. According to its position of
occurrence in the number, each digit is weighted. Towards the left the weights increases by
a constant factor equivalent to the base or radix. With the help of the radix point (‗.‘), the
positions corresponding to integral weights (1) are differentiated from the positions
corresponding to fractional weights (<1). Any integer value that is greater than or equal to
two can be used as the base or radix. The digit position ‗n‘ has weight rn

6 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

. Largest value of digit position is always 1 less than the base value. The value of a number
is weighted sum of its digits. For example:
1358 = 1 x 103 + 3 x 102 + 5 x 101 + 8 x 100
13.58 = 1 x 101 + 3 x 100 + 5 x 10−1 + 8 x 10−2
Few examples of positional number system are decimal number system, Binary number
system, octal number system, hexadecimal number system, BCD, etc.

2. Non-Positional (or Non-weighted) Number System:

Non-positional number system is also known as non-weighted number system. Digit value
is independent of its position. Non-positional number system is used for shift position
encodes and error detecting purpose. Few examples of non-weighted number system are
gray code, roman code, excess-3 code, etc.

Types of Number Systems

There are various types of number systems in mathematics. The four most common number
system types are:

1. Decimal number system (Base- 10)

2. Binary number system (Base- 2)

3. Octal number system (Base-8)

4. Hexadecimal number system (Base- 16)

Decimal Number System

In the decimal number system, the numbers are represented with base 10. The way of
denoting the decimal numbers with base 10 is also termed as decimal notation. This number
system is widely used in computer applications. It is also called the base-10 number system
which consists of 10 digits, such as, 0,1,2,3,4,5,6,7,8,9. Each digit in the decimal system has
a position and every digit is ten times more significant than the previous digit.

7 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Suppose, 25 is a decimal number, then 2 is ten times more than 5. Some examples of
decimal numbers are:-

(12)10, (345)10, (119)10, (200)10, (313.9)10

Let us see some more examples:

(92)10 = 9×101+2×100

(200)10 = 2×102+0x101+0x100

The decimal numbers which have digits present on the right side of the decimal (.) denote
each digit with decreasing power of 10. Some examples are:

(30.2)10= 30×101+0x100+2×10-1

(212.367)10 = 2×102+1×101+2×100+3×10-1+6×10-2+7×10-3

Binary Number System

In the binary number system, the numbers are represented with base 2. A computer can
understand only the ―ON‖ and ―OFF‖ state of a switch. These two states are represented
by 1 and 0. The combination of 1 and 0 form binary numbers. These numbers represent
various data. As two digits are used to represent numbers, it is called a binary or base 2
number system.

The binary number system uses positional notation. But in this case, each digit is multiplied
by the appropriate power of two based on its position.

8 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

For example, (101101)2 in decimal is

= 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20

In binary, the most significant bit (MSB) is the bit on the far left end of a number, and the
least significant bit (LSB) is the bit on the far right end. The MSB has the greatest effect on
the number and usually has the largest value. For example, in the binary number 1000, the
MSB is 1, and in the binary number 0111, the MSB is 0.

Units of measurement of data

Machine language is binary. And so it is necessary to discuss how to measure the data
stored in a computer. Bit and Byte are the units to measure data.

Bit

The term ‗bit‘ is a contraction of the words ‗binary‘ and ‗digit‘. It is the smallest unit of
memory or instruction that can be given or stored on a computer. A bit is either a 0 or a 1.
The number in the above example is a 6-bit number as it has 6 binary digits (0s and 1s).

Byte

A group of 8 bits like 01100001 is a byte. Combination of bytes comes with various names
like the kilobyte. One kilobyte is a collection of 1000 bytes.

Octal Number System

Octal Number System is one the type of Number Representation techniques, in which there
value of base is 8. That means there are only 8 symbols or possible digit values, there are 0,
1, 2, 3, 4, 5, 6, 7. It requires only 3 bits to represent value of any digit. Octal numbers are
indicated by the addition of either an 0o prefix or an 8 suffix.

9 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Position of every digit has a weight which is a power of 8. Each position in the Octal system
is 8 times more significant than the previous position, that means numeric value of an octal
number is determined by multiplying each digit of the number by the value of the position
in which the digit appears and then adding the products. So, it is also a positional (or
weighted) number system.

The number 65.125 is interpreted as

65.125 =1x82+0x81+1x80+1x8-1

This number system is mainly used in computer programming as it is a compact way of


representing binary numbers with each octal number corresponding to three binary digits.

Hexadecimal Number System

The word hexadecimal can be divided into 'Hexa' and 'deci', where 'Hexa' means 6 and 'deci'
means 10. The hexadecimal number system is described as a 16 digit number representation
of numbers from 0 - 9 and digits from A - F. In other words, the first 9 numbers or digits are
represented as numbers while the next 6 digits are represented as symbols from A - F.
Hexadecimal is very similar to the decimal number system that has a base number of 9.

10 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Therefore, after 9 digits, the 10th digit is represented as a symbol - 10 as A, 11 as B, 12 as


C, 13 as D, 14 as E, and 15 as F. Hence, the 16 digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,
E, F. For example: 7B316, 6F16, 4B2A16, 7B316, 6F16, 4B.2A16 are hexadecimal numbers.

A hexadecimal number system is also known as a positional number system as each digit
has a weight of power 16. Each digit is 16 times more significant than the previous digit.
Hence, when we convert any hexadecimal number to any other number system, we multiply
the digits individually keeping the power of 16 in mind according to the placement of their
position.

Example: (9AB.47)16 is a Hexadecimal Number

The Number is written in expanded form as

9 x 162 x A x 161 + B x 160 + 4 x 16-1 + 7 x 16-2

1. (AE5)16 = A × 162 + E × 161 + 5 × 160

Hexadecimal Conversion Table:

Hexadecimal Numbers can also be represented in Binary, Octal and Decimal form. The
table below denotes the representation of a Hexadecimal digit in other forms.

11 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Disadvantages of using Hexadecimal System

In the Hexadecimal System, 16 digits ranging from 0 to 9 and A to F, are used to represent
any Number. The Hexadecimal System is preferred over any other System as it saves space
in representing larger Numbers. However, there are some disadvantages too of using the
Hexadecimal System, which is as follows:

 Difficult to read and write

 Troublesome for operations like multiplication and division

 Is the most difficult language while dealing with computer data

 Number System Conversions

Conversion from Decimal to Binary:

1. Steps to convert decimal number to binary number:

 Step 1: Divide the given decimal number by 2.

12 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

 Step 2: Take the remainder and record it on the right side.


 Step 3: Repeat the Step 1 and Step 2 until the decimal number cannot be divided further.
 Step 4: The first remainder will be the LSB and the last remainder is the MSB. The equivalent
binary number is then written from left to right i.e. from MSB to LSB.

Example: To convert the decimal number 87(10) to binary.

 So 87 decimal is written as 1010111 in binary.


 It can be written as 87(10)= 1010111(2)

2. Steps to convert decimal fraction number to binary number:

 Step 1: Multiply the given decimal fraction number by 2.

 Step 2: Note the carry and the product.

 Step 3: Repeat the Step 1 and Step 2 until the decimal number is zero.

 Step 4: The first carry will be the MSB and the last carry is the LSB. The equivalent binary

fraction number is written from MSB to LSB.

Example 1: To convert the decimal number 0.3125(10) to binary.

Multiply by 2 Carry Product


0.3125 x 2 0 (MSB) 0.625
0.625 x 2 1 0.25
0.25 x 2 0 0.50
0.50 x 2 1 (LSB) 0.00
0.00

 Therefore, 0.3125(10) = 0.0101(2)


OR

13 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Example 2: To convert the decimal number 152.671875(10) to binary.

3. Steps to convert binary number to decimal number

 Step 1: Start at the rightmost bit.

14 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

 Step 2: Take that bit and multiply by 2n, when n is the current position beginning at 0
andincreasing by 1 each time. This represents a power of two.
 Step 3: Then, add all the products.
 Step 4: After addition, the resultant is equal to the decimal value of the binary number.

Example 1: To convert the binary number 1010111(2) to decimal.

 Therefore, 1010111(2) = 87(10)

Example 2: To convert the binary number 11011.101(2) to decimal.

= 1x24 + 1x23 + 0x22 + 1x21 + 1x20 + 1x2-1 + 0x2-2 + 1x2-3


= 1x16 + 1x8 + 0x4+ 1x2 + 1x1 + 1x0.5+ 0x0.25+ 1x0.125
= 16 + 8 + 2 + 1 + 0.5 + 0.125
= 27.625(10)
OR
4 3 2
Weights 2 2 2 21 20 2-1 2-2 2-3
Digits 1 1 0 1 1 1 0 1
Values 16 8 4 2 1 0.5 0.25 0.125

 Therefore, 11011.101(2) = 27.625(10)

Conversion from Decimal to Octal

1. Steps to convert decimal number to octal number

 Step 1: Divide the given decimal number by 8.


 Step 2: Take the remainder and record it on the side.
 Step 3: Repeat the Step 1 and Step 2 until the decimal number cannot be divided further.
 Step 4: The first remainder will be the LSB and the last remainder is the MSB. The equivalent
octal number is then written from left to right i.e. from MSB to LSB.

15 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS
Example 1: To convert the decimal number 3034(10) to octal number.

 So 3034 decimal is written as 5732 in octal.


 It can be written as 3034(10) = 5732(8)

 Note: If the number is less than 8 the octal number is same as decimal number.

Example 2: To convert the decimal number 0.3125(10) to octal number.

0.3125 x 8 = 2.5000 2

0.5000 x 8 = 4.0000 4

 Therefore, 0.3125(10) = 0.24(8)


2. Steps to convert octal number to decimal number

 Step 1: Start at the rightmost bit.


 Step 2: Take that bit and multiply by 8n, when n is the current position beginning at 0
andincreasing by 1 each time. This represents the power of 8.
 Step 3: Then, add all the products.
 Step 4: After addition, the resultant is equal to the decimal value of the octal number.

Example 1: To convert the octal or base-8 number 5732(8) to decimal

 Therefore, 5732(8) = 3034(10)

Example 2: To convert the octal number 234.56(8) to decimal number.

= 2x82 + 3x81 + 4x80 + 5x8-1 + 6x8-2


= 2x64+ 3x8 + 4x1 + 5x0.125+ 6x0.015625

16 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS
= 128 + 24 + 4 + 0.625 + 0.09375
= 156.71875(10)
OR
Weights 82 81 80 8-1 8-2
Digits 2 3 4 5 6
Values 64 8 1 0.125 0.015625

 Therefore, 234.56(8) = 156.71875(10)

Conversion from Decimal to Hexadecimal

1. Steps to convert decimal number to hexadecimal number

 Step 1: Divide the decimal number by 16.

 Step 2: Take the remainder and record it on the side.

 Step 3: Repeat the Step 1 and Step 2 until the decimal number cannot be divided
further.

 Step 4: The first remainder will be the LSB and the last remainder is the MSB. The
equivalent hexadecimal number is then written from left to right i.e. from MSB to
LSB.

Example To convert the decimal number 16242(10) to hexadecimal

 So 16242 decimal is written as 3F72 in hexadecimal.

 It can be written as 16242(10) = 3F72 (16)

 Note: If the number is less than 16 the hexadecimal number is same as decimal
number.

2. Steps to convert hexadecimal number to decimal number

 Step 1: Start at the rightmost bit.

17 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS
n
 Step 2: Take that bit and multiply by 16 , where n is the current position beginning
at 0 and increasing by 1 each time. This represents a power of 16.

 Step 3: Then, add all the products.

 Step 4: After addition, the resultant is equal to the decimal value of the
hexadecimal number.

Example 1: To convert the Hexadecimal or base-16 number 3F72 to a decimal number.

Therefore, 3F72(16)= 16242(10)

Example 2: To convert the hexadecimal number 5AF.D(16) to decimal number.

= 5x162 + 10x161 + 15x160 + 13x16-1

= 5x256+ 10x16 + 15x1 + 13x0.0625

= 1280 + 160 + 15 + 0.8125

= 1455.8125(10)

OR

Weights 162 161 160 16-1

Digits 5 A F D

Values 256 16 1 0.0625

18 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

 Therefore, 5AF.D(16) = 1455.8125(10)

Conversion from Binary to Octal

Steps to convert Binary to octal

 Take a binary number in groups of 3 and use the appropriate octal digit in its place.

 Begin at the rightmost 3 bits. If we are not able to form a group of three, insert 0s to
the left until we get all groups of 3 bits each.

 Write the octal equivalent of each group. Repeat the steps until all groups have
been converted.

Example 1: Consider the binary number 1010111(2)

001 010 111

1 2 7

Therefore, 1010111(2) = 127 (8)

Example 2: Consider the binary number 0.110111(2)

000 . 110 111

0 6 7

Therefore, 0.110111 (2) = 0.67 (8)

Example 3: Consider the binary number 1101.10111(2)

001 101 . 101 110

1 5 5 6

Therefore, 1101.10111(2) = 15.56 (8)

19 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Note: To make group of 3 bits, for whole numbers, it may be necessary to add a 0‘s to the
left of MSB

and when representing fractions, it may be necessary to add a 0‘s to right of LSB.

Conversion from Octal to Binary

Steps to convert octal to binary

 Step 1: Take the each digit from octal number

 Step 2: Convert each digit to 3-bit binary number. (Each octal digit is represented
by a three- bit binary number as shown in Numbering System Table)

Octal digit 0 1 2 3 4 5 6 7

Binary 000 001 010 011 100 101 110 111


Equivalent

Example 1: Consider the octal number 456(8) into binary

4 100

5 101

6 110

Therefore, 456(8) = 100101110 (2)

Example 2: Consider the octal number 73.16(8) into binary

7 111

3 011

1 001

20 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

6 110

Therefore, 73.16(8) = 111011.001110 (2)

Conversion from Binary to Hexadecimal

Steps to convert Binary to Hexadecimal

 Take a binary number in groups of 4 and use the appropriate hexadecimal digit in
its place.

 Begin at the rightmost 4 bits. If we are not able to form a group of four, insert 0s to
the left until we get all groups of 4 bits each.

 Write the hexadecimal equivalent of each group. Repeat the steps until all groups
have been converted.

Example 1: Consider the binary number 1011001(2)

0101 1001

5 9 Therefore, 1011001 (2) = 59 (16)

Example 2: Consider the binary number 0.11010111(2)

0 1101 0111

0 D 7

Therefore, 0.110111 (2) = 0.D7 (16)

Conversion from Hexadecimal to Binary

Steps to convert hexadecimal to binary

 Step 1: Take the each digit from hexadecimal number

21 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

 Step 2: Convert each digit to 4-bit binary number. (Each hexadecimal digit is
represented by a four-bit binary number as shown in Numbering System Table)

Example: Consider the hexadecimal number CEBA (16)

Therefore, CEBA (16) = 1100 1110 1011 1010 (2)

Conversion from Octal to Hexadecimal

Steps to convert Octal to Hexadecimal

Using Binary system, we can easily convert octal numbers to hexadecimal numbers and
vice-versa

 Step 1: write the binary equivalent of each octal digit.

 Step 2: Regroup them into 4 bits from the right side with zeros added, if necessary.

 Step 3: Convert each group into its equivalent hexadecimal digit.

Example: Consider the octal number 274 (8)

2 010

7 111

4 100

Therefore, 274 (8) = 010 111 100 (2)


22 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE
DIGITAL ELECTRONICS

Group the bits into group of 4 bits as 0 1011 1100

0000 1011 1100

0 B C Therefore, 274 (8) = BC (2)

Conversion from Hexadecimal to Octal

Steps to convert Hexadecimal to Octal

 Step 1: write the binary equivalent of each hexadecimal digit.

 Step 2: Regroup them into 3 bits from the right side with zeros added, if necessary.

 Step 3: Convert each group into its equivalent octal digit.

Example: Consider the hexadecimal number FADE (16)

F 1111
A 1010
D 1101
E 1110

Therefore, FADE (16) = 1111 1010 1101 1110 (2)

Group the bits into group of 3 bits from LSB as 001 111 101 011 011 110

001 111 101 011 011 110

1 7 5 3 3 6

Therefore, FADE (16)= 175336 (8)

23 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


DIGITAL ELECTRONICS

Binary Arithmetic
Binary arithmetic is essential in all types of digital systems. To understand these systems, you must
know the basics of binary addition, subtraction, multiplication,and division.

Binary Addition
The four basic rules for adding binary digits (bits) are as follows:0 + 0 = 0 Sum of 0

with a carry of 0
0 + 1 = 1 Sum of 1 with a carry of 0
1 + 0 = 1 Sum of 1 with a carry of 0
1 + 1 = 10 Sum of 0 with a carry of 1

Notice that the first three rules result in a single bit and in the fourth rule the addition of two 1s yields a
binary two (10). When binary numbers are added, the last condition creates a sum of 0 in a given
column and a carry of 1 over to the next column to the left, as illustrated in the following examples:

Example: Add 11 + 1

Sol.

Carry Carry
1 1
0 1 1
+ 0 0 1
1 0 0
In the right column, 1 + 1 = 0 with a carry of 1 to the next column to the left. In the middle column, 1 +
1 + 0 = 0 with a carry of 1 to the next column to the left.In the left column, 1 + 0 + 0 = 1.
Carry bits
1+0+0=01 Sum of 1 with a carry of 0
1+1+0=10 Sum of 0 with a carry of 1
1+0+1=10 Sum of 0 with a carry of 1
1+1+1=11 Sum of 1 with a carry of 1

18 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Example: Add 111 + 11

Sol.

Carry Carry

1 1
1 1 1
+ 1 1
1 0 1 0

Binary Subtraction
The four basic rules for subtracting bits are as follows:

0-0=0
1-1=0
1-0=1
10 - 1 = 1 0 - 1 with a borrow of 1

When subtracting numbers, you sometimes have to borrow from the next columnto the left. A borrow is
required in binary only when you try to subtract a 1 from a 0. In this case, when a 1 is borrowed from
the next column to the left, a 10 is created in the column being subtracted, and the last of the four basic
rules just listed must be applied.

Example: Subtract 0112 from 1012.

Sol.
Left column: Middle column:
When a 1 is borrowed, Borrow 1 from next column
a 0 is left, so 0 - 0 = 0. to the left, making a 10 in this column,
then 10 - 1 = 1.
1 1 0 01
- 0 1 1
0 1 0

19 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Binary Multiplication
The four basic rules for multiplying bits are as follows:

0 × 0 = 0, 0 × 1 = 0, 1 × 0 = 0, 1×1=1
Multiplication is performed with binary numbers in the same manner as with

Sol.

20 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Complements of Binary Numbers
The 1‘s complement and the 2‘s complement of a binary number are important because they permit the
representation of negative numbers. The method of 2‘s complement arithmetic is commonly used in
computers to handle negative numbers.

Finding the 1’s Complement


The 1‘s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s, as
illustrated below:

The simplest way to obtain the 1‘s complement of a binary number with a digital circuit is to use
parallel inverters (NOT circuits), as shown in Figurebelow for an 8-bit binary number.

Example of inverters used to obtain the 1‘s complement of a binary number.

Finding the 2’s Complement


The 2‘s complement of a binary number is found by adding 1 to the LSB of the1‘s complement. 2‘s
complement = (1‘s complement) + 1

21 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Example: Find the 2‘s complement of 10111000 using the alternative method.Sol.

Related Problem:
Find the 2’s complement of 11000000.

The 2’s complement of a negative binary number can be realized using


inverters and an adder, as indicated in Figure below. This illustrates how an 8-
bit number can be converted to its 2’s complement by first inverting each bit
(taking the 1’s complement) and then adding 1 to the 1’s complement with an
adder circuit.

Example of obtaining the 2‘s complement of a negative binary number.

To convert from a 1‘s or 2‘s complement back to the true (uncomplemented) binary form, use
the same two procedures described previously. To go from the 1‘s complement back to true binary,
reverse all the bits. To go from the 2‘s complement form back to true binary, take the 1‘s complement
of the 2‘s complement number and add 1 to the least significant bit.

22 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


1’s Complement Form
Positive numbers in 1‘s complement form are represented the same way as the positive sign-magnitude
numbers. Negative numbers, however, are the 1‘s complements of the corresponding positive numbers.
For example, using eight bits, the decimal number 225 is expressed as the 1‘s complement of +25
(00011001) as
11100110
In the 1‘s complement form, a negative number is the 1‘s complement of thecorresponding positive
number.

Example: Find the 1‘s complement of 00010011.Sol.


Change each bit in a number to get the 1‘s complement. The 1‘s complement ofa binary number is
found by changing all 1s to 0s and all 0s to 1s, as illustrated below:

0 0 0 1 0 0 1 1 Binary number

↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓

1 1 1 0 1 1 0 0 1's complement

2’s Complement Form


Positive numbers in 2‘s complement form are represented the same way as in the sign magnitude and
1‘s complement forms. Negative numbers are the 2‘s complements of the corresponding positive
numbers. Again, using eight bits, let‘s take decimal number 225 and express it as the 2‘s complement of
+25 (00011001).Inverting each bit and adding 1, you get

-25 = 11100111

In the 2‘s complement form, a negative number is the 2‘s complement of the corresponding positive
number.

23 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Example: Represent −2 in 2‘s complement.

Sol.

2 = 0 0 1 0

1 1 0 1 1‘s complement

+ 1 results in 2‘s complement

1 1 1 0 = -2

Binary Coded Decimal (BCD)

Binary coded decimal (BCD) is a way to express each of the decimal digits with abinary code. There are
only ten code groups in the BCD system, so it is very easy to convert between decimal and BCD.
Because we like to read and write in decimal, the BCD code provides an excellent interface to binary
systems. Examples of such interfaces are keypad inputs and digital readouts.

The 8421 BCD Code


The 8421 code is a type of BCD (binary coded decimal) code. Binary coded decimal means that each
decimal digit, 0 through 9, is represented by a binary codeof four bits. The designation 8421 indicates the
binary weights of the four bits (23, 22, 21, 20). The ease of conversion between 8421 code numbers and
the familiar decimal numbers is the main advantage of this code. All you have to remember are the ten
binary combinations that represent the ten decimal digits as shown in Table below. The 8421 code is
the predominant BCD code, and when we refer to BCD, we always mean the 8421 code unless
otherwise stated.

In BCD, 4 bits represent each decimal digit.

24 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Invalid Codes
You should realize that, with four bits, sixteen numbers (0000 through 1111) can be represented but
that, in the 8421 code, only ten of these are used. The six code combinations that are not used—1010,
1011, 1100, 1101, 1110, and 1111—are invalid in the 8421 BCD code.
To express any decimal number in BCD, simply replace each decimal digit with the appropriate 4-bit
code, as shown by example below.

Example: Convert each of the following decimal numbers to BCD:(a) 35 (b) 98 (c) 170

(d) 2469

Sol.

It is equally easy to determine a decimal number from a BCD number. Start at the right-most bit and
break the code into groups of four bits. Then write the decimaldigit represented by each 4-bit group.

Example: Convert each of the following BCD codes to decimal:

(a) 10000110 (b) 001101010001 (c) 1001010001110000

Sol.

25 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Applications
Digital clocks, digital thermometers, digital meters, and other devices with seven- segment displays
typically use BCD code to simplify the displaying of decimal numbers. BCD is not as efficient as
straight binary for calculations, but it is particularly useful if only limited processing is required, such
as in a digital thermometer.

BCD Addition
BCD is a numerical code and can be used in arithmetic operations. Addition is the most important
operation because the other three operations (subtraction, multiplication, and division) can be
accomplished by the use of addition. Here is how to add two BCD numbers:

Step 1: Add the two BCD numbers.


Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated, it is an invalid
result. Add 6 (0110) to the 4-bit sum in order to skip thesix invalid states and return the code to 8421. If
a carry results when 6 is added, simply add the carry to the next 4-bit group.

Example: Add the following BCD numbers:


(a) 0011 + 0100 (b) 00100011 + 00010101
(c) 10000110 + 00010011 (d) 010001010000 + 010000010111
Sol.

Note that in each case the sum in any 4-bit column does not exceed 9, and theresults are valid BCD
numbers.

26 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Example: Add the following BCD numbers:(a) 1001 + 0100
(b) 1001 + 1001
(c) 00010110 + 00010101 (d) 01100111 + 01010011

Sol.

27 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Advantages of BCD Codes Disadvantages of BCD Codes
1. BCD coding is similar to the 1. Each decimal number requires fourbits
binary equivalent of decimal to be represented in the BCD code.
numbers 0–9. 2. Arithmetic operations in BCD or
2. BCD has no limitation for numbersize. weighted codes are much complicated
as it deals with morenumber of bits
and also it has different set of rules.
3. BCD is less efficient than binary.
3. It is easier to convert decimal
numbers from or to BCD than to
binary form.

Digital Codes
Many specialized codes are used in digital systems. You have just learned about the BCD code; now
let‘s look at a few others. Some codes are strictly numeric, like BCD, and others are alphanumeric; that
is, they are used to represent numbers, letters, symbols, and instructions. The codes introduced in this
section are the Excess-3 code, Graycode, the ASCII code, and the Unicode.

Excess-3 Code

The excess-3 code, abbreviated as XS-3, is an important 4-bit code sometimes used with binary-coded
decimal (BCD) numbers. It possesses advantages in certain arithmetic operations.

The excess-3 code for a decimal number can be obtained in the same manner as BCD except that 3 is
added to each decimal digit before encoding it in binary. For example, to encode the decimal digit 5
into excess-3 code, we must first add 3 to obtain 8. The digit 8 is encoded in its equivalent 4-bit binary
code 1000. As another example, let us convert 26 into its excess-3 code representation.

Since no definite weights can be assigned to the four digit positions, excess-3 is an unweighted code.
Excess-3 codes for decimal digits 0 through 9 are given in Table 44.7. The noteworthy point from the
Table 44.6 is that both codes (BCD and excess-3) use only 10 of the 16 possible 4-bit code groups. The
excess-3 codes, however, does not use the same code groups. For excess-3 codes, the invalid code
28 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE
groups are 0000, 0001, 0010, 1101, 1110 and 1111.

The key feature of the excess-3 codes is that it is self-complementing code. It means that 1‘s
complement of the coded number yields 9‘s complement of the number itself. For example, excess-3
code of decimal 5 is 1000, its 1‘s complement is 0111, which is excess-3 code for decimal 4, which is
9‘s complement of 5.

It should be noted that the 1‘s complement is easily produced with digital logic circuits by simply
inverting each bit. The self-complementing property makes the excess-3 code useful in some arithmetic
operations, because subtraction can be performed using the 9‘s complement method.

Example : Encode the decimal number 2345 in BCD and excess-3 codes.

Solution:

Example : Encode (1236)10 In excess-3 code.

Solution:

29 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


The Gray Code
The Gray code is unweighted and is not an arithmetic code; that is, there are no specific weights
assigned to the bit positions. The important feature of the Gray code is that it exhibits only a single bit
change from one code word to the next in sequence. This property is important in many applications,
such as shaft position encoders, where error susceptibility increases with the number of bit changes
between adjacent numbers in a sequence. The table below is a listing of the 4-bit Gray code for decimal
numbers 0 through 15. Binary numbers are shown in the table for reference. Like binary numbers, the
Gray code can have any number of bits. Notice the single-bit change between successive Gray code
words. For instance, in going from decimal 3 to decimal 4, the Gray code changes from 0010 to 0110,
while the binary code changes from 0011 to 0100, a change of three bits.The only bit change in the Gray
code is in the third bit from the right: the other bits remain the same.

The single bit change characteristic of the Gray code minimizes the chance forerror.

Binary-to-Gray Code Conversion


Conversion between binary code and Gray code is sometimes useful. Thefollowing rules explain how to
convert from a binary number to a Gray code word:
30 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE
1. The most significant bit (left-most) in the Gray code is the same as thecorresponding MSB
in the binary number.
2. Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit.
Discard carries.

Example: The conversion of the binary number 10110 to Gray code is as


Sol.

The Gray code is 11101.


Gray-to-Binary Code Conversion
To convert from Gray code to binary, use a similar method; however, there aresome differences. The
following rules apply:
1. The most significant bit (left-most) in the binary code is the same as thecorresponding bit in
the Gray code.

2. Add each binary code bit generated to the Gray code bit in the next adjacentposition.
Discard carries.

Example: The conversion of the Gray code word 11011 to binary is as follows:

Sol.

The binary number is 10010.

Example: (a) Convert the binary number 11000110 to Gray code.


(b) Convert the Gray code 10101111 to binary.

Sol.

31 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Alphanumeric codes
In order to communicate, you need not only numbers but also letters and other symbols. Alphanumeric
codes are codes that represent numbers and alphabetic characters (letters). At a minimum, an
alphanumeric code must represent 10 decimal digits and 26 letters of the alphabet, for a total of 36
items. This number requires six bits in each code combination because five bits are insufficient (25
= 32). There are 64 total combinations of six bits, so there are 28 unused codecombinations.
We need spaces, periods, colons, semicolons, question marks, etc. We also need instructions to tell
the receiving system what to do with the information. With codes that are six bits long, we can handle
decimal numbers, the alphabet, and 28other symbols.

ASCII
ASCII is the abbreviation for American Standard Code for Information Interchange. Pronounced
―askee,‖ ASCII is a universally accepted alphanumeric code used in most computers and other
electronic equipment. Most computer keyboards are standardized with ASCII. When you enter a letter,
a number, or control command, the corresponding ASCII code goes into the computer.

ASCII has 128 characters and symbols represented by a 7-bit binary code. Actually, ASCII can be
considered an 8-bit code with the MSB always 0. This 8-bit code is 00 through 7F in hexadecimal. The
first 32 ASCII characters are nongraphic commands that are never printed or displayed and are used
only for control purposes. Examples of the control characters are ―null,‖ ―line feed,‖ ―start of the text,‖
and ―escape.‖ The other characters are graphic symbols that can be printed or displayed and include the
letters of the alphabet (lowercase and uppercase), the ten decimal digits, punctuation signs, and other
commonly used symbols.

Info Note: A computer keyboard has a dedicated microprocessor that constantly scans keyboard circuits
to detect when a key has been pressed and released. A unique scan code is produced by computer
software representing that particular key. The scan code is then converted to an alphanumeric code
(ASCII) for use bythe computer.

32 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


The ASCII Control Characters
The first 32 codes in the (ASCII Table) below represent the control characters. These are used to allow
devices such as a computer and printer to communicate with each other when passing information and
data. The control key function allows a control character to be entered directly from an ASCII keyboard
by pressing the control key (CTRL) and the corresponding symbol.

33 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE


Example Use ASCII table to determine the binary ASCII codes that are entered from the computer‘s
keyboard when the following C language program statement is typed in. Also express each code in
hexadecimal. If (x > 5)
Sol.
The ASCII code for each symbol is found in ASCII table.

34 Mr. Guruprasad T R | Faculty, Dept. Of BCA, BITS HI-TECH COLLEGE

You might also like