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

Different Types of Code Lecture-08

The document discusses various types of codes used in digital electronics, including weighted binary codes, non-weighted codes, error detecting and correcting codes, and alphanumeric codes. It explains the concept of codes as symbolic representations of information, particularly focusing on weighted binary codes like BCD and 2421, as well as non-weighted codes like Excess-3. The lecture outlines the principles of encoding and decoding data for digital computers.

Uploaded by

mohitburnwal2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Different Types of Code Lecture-08

The document discusses various types of codes used in digital electronics, including weighted binary codes, non-weighted codes, error detecting and correcting codes, and alphanumeric codes. It explains the concept of codes as symbolic representations of information, particularly focusing on weighted binary codes like BCD and 2421, as well as non-weighted codes like Excess-3. The lecture outlines the principles of encoding and decoding data for digital computers.

Uploaded by

mohitburnwal2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Paper Name: Digital Electronics

Paper Code: BCAC-102

Lecture#08
Codes in Digital Electronics

Dr. Dibyendu Kumar Pal ,


M.Sc.(Applied Maths), MCA, Ph.D.
HOD & Assistant Professor
Department of Computer Application
Asansol Engineering College, West Bengal, India.
Lecture Outline

What is Code?

Different Types of Codes

• Weighted Binary Codes


• Non weighted codes
• Error detecting codes
• Error correcting codes
• Alphanumeric codes
What is Code?
Code is a symbolic representation of discrete information, which
may be present in the form of numbers, letters or physical
quantities. The symbols used are the binary digits 0 and 1 which
are arranged according to the rules of codes. These codes are used
to communicate information to a digital computer to retrieve
messages from it. A code is used to enable an operator to feed data
into a computer directly, in the form of decimal numbers, alphabets
and special characters. The computer converts this data into binary
codes and after computation, transforms the data into its original
format (decimal numbers, alphabets and special characters).
When numbers, letters, or words are represented by a
special group of symbols, this is called encoding, and the
group of symbols is called a code. In Morse code, a series of
dots and dashes represent alphabet, numerals and special
characters.
Codes are broadly classified into five groups, viz., i)
Weighted Binary Codes, ii) Non-weighted Codes, iii) Error
– detecting Codes iv) Error-correcting Codes and v)
Alphanumeric Codes.
Weighted Binary Codes:
Weighted binary codes obey their positional weighting principles.
Each position of a number represents a specific weight. In a
weighted binary code, the bits are multiplied by the weights
indicated; the sum of these weighted bits gives the equivalent
decimal digits.
Straight binary coding is a method of representing a decimal
number by its binary equivalent. The codes 8421, 2421, 5421,
5211 are weighted binary codes. Each decimal digit is
represented by a four-bit binary word, the three digits for the left
being weighted. Table 1. consists of a few weighted 4-bit binary
codes with their decimal numbers and complements.
Page-10

Decimal 8421 5421 2421 9’s complement


number of 2421 code

0 0000 0000 0000 1111


1 0001 0001 0001 1110
2 0010 0010 0010 1101
3 0011 0011 0011 1100
4 0100 0100 0100 1011
5 0101 1000 1011 0100
6 0110 1001 1100 0011
7 0111 1010 1101 0010
8 1000 1011 1110 0001
9 1001 1100 1111 0000
BCD or 8421 Code:
The binary coded decimal (BCD) uses the binary number system to
specify the decimal numbers 0 to 9. It has four bits. The weights are
assigned according to the positions occupied by these digits. The weights
of the first (right-most) position is (1), the second (2), the third (4), and
the fourth (8). Reading from left to right , the weights are 8-4-2-1 and
hence it is called 8421 code.
The binary equivalent of 7 is , but the same number is represented in
BCD in 4-bit form as . Also, the numbers from 0 to 9 are represented in
the same way as in binary system, but after 9 the representations in BCD
are different. For example, the decimal number 12 in the binary system is
but the same number is represented as [0001 0010] in BCD.
Give the BCD code for the decimal number 874.

Solution:
Decimal Number is 8 7 4

BCD code is 1000 0111 0100

Hence, (874)10 = (1000 0111 0100)BCD


2421 Code:

This is a weighted code; its weight are 2, 4, 2, 1. A decimal


number is represented in 4-bit form and the total weight of
the four bits=2+4+2+1=9. Hence the 2421 code represents
decimal numbers from 0 to 9. Up to 4, the 2421 code is the
same as that in BCD; however it varies for digits from 5 to
9. The bit combination 1101, when weighted by the
reflective digits 2421, gives decimal equivalent of=
2x1+4x1+2x0+1x1= 2+4+0+1=7
Reflective Codes:
A code is said to be reflective when the code for 9 is the
complement of the code for 0, 8 for 1, 7 for 2, 6 for 3, and 5 for 4.
While the 2421, 5211 and Excess-3 codes are reflective codes, the
8421 code is not. Table

Sequential codes:
A code can said to be sequential when each succeeding code is one
binary number greater than its preceding code. This greatly helps
mathematical manipulation of data. While the 8421 and Excess-3
codes are sequential, the 2421 and 5421 codes are not.
Non-weighted codes:
Non-weighted codes are codes that are not positionally weighted. This means
that each position within a binary number is not assigned a fixed value. Excess-
3 codes and Gray codes are examples of non-weighted codes.

Excess-3 code:
As the name indicates, the excess-3 represents a decimal number, in binary
form, as a number greater than 3. An excess-3 code is obtained by adding 3 to a
decimal number. For example, to encode the decimal number 6 into an excess-
3 code, we must first add 3 in order to obtain 9.The 9 is then encoded in its
equivalent 4-bit binary code 1001.The excess-3 code is a self-complementing
code, and this helps in performing subtraction operations in digital computers,
especially in the earlier models. The excess-3 code is also a reflective code.
Convert into its Excess-3 code.

Solution :
Decimal number 6 4 3
Add 3 to each bit +3 +3 +3
Sum 9 7 6

Converting the above sum into its BCD code, we have

Sum 9 7 6

BCD 1001 0111 0110

Hence, the Excess-3 code for is 1001 0111 0110


Decimal 8421(BCD) code Excess-3 code
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100

You might also like