In this tutorial, you will learn about codes in the number system, including their definitions and classifications. You will explore Binary Coded Decimal (BCD), its conversions, advantages, and disadvantages. Additionally, you will discover Morse code applications and compare BCD with other weighted codes.
Contents:
- What are Codes in Number System?
- Classification of Codes
- What is BCD?
- Features of BCD Codes
- Conversion of Decimal to BCD
- Conversion of BCD to Decimal
- Interconversion of BCD and Binary Numbers
- Advantages of BCD
- Disadvantages of BCD
- Advantages of Binary Coding System
- Morse Code and Its Applications
- Differences Between BCD and Morse Code
- Baudot Coding System and Its Evolution
- Other Weighted Codes
- Comparison Between BCD and Other Weighted Codes
What are Codes in Number System?
- They are the group of symbols which are used to represent numbers, words and characters.
- Codes are generally used for secret data communications because when a message is represented in a code then visibility of the actual message is hidden from the outside world.
- Encoders and decoders are generally used for coding in number system because codes are frequently encoded and decoded.
Classification of Codes
Codes can be classified as weighted or unweighted codes, sequential or non-sequential codes, and complementary or non-complementary codes. Here are the definitions of each:
- Weighted and Unweighted code
- Weighted Code: – If we express numbers as the sum of some other specific numbers, it is known as weighted code. These specific numbers are called positional weights. Examples of weighted code are BCD and 2-4-2-1 code.
- Unweighted Code: – Unweighted codes do not use positional weights. Unweighted codes are usually a result of performing some logical operations on an existing weighted code. Some examples are Gray code and Excess-3 code.
- Sequential and Non-sequential code
- Sequential Code: – In sequential codes, code for a number can be obtained by adding one to its previous number’s code. Examples of sequential codes are BCD and Excess-3 code.
- Non-Sequential Code: – In non-sequential codes, code for a number cannot be obtained by adding one to its previous number’s code. An example of non-sequential code is the 2-4-2-1 code
- Self-Complementary and Non-self-complementary code
- Self-Complementary: – In self-complementary code, 9’s complement of a decimal number can be obtained by 1’s complement of its coded form. Examples of self-complementary code are 2-4-2-1 and Excess-3 code.
- Non-self-complementary: – In non-self-complementary code, there is no relation between a decimal number and its coded form. Numbers in this type of code cannot be obtained using complements. An example of this is the BCD code.
What is BCD?
BCD stands for binary coded decimal. It is another way of representing decimal numbers. It is a weighted code with positional values as 8-4-2-1. In BCD representation, we write decimal numbers as encodings of 4-binary bits. Here is a table that represents BCD.
DECIMAL NUMBER | BCD ( 8 4 2 1 ) |
---|---|
0 | 0 0 0 0 |
1 | 0 0 0 1 |
2 | 0 0 1 0 |
3 | 0 0 1 1 |
4 | 0 1 0 0 |
5 | 0 1 0 1 |
6 | 0 1 1 0 |
7 | 0 1 1 1 |
8 | 1 0 0 0 |
9 | 1 0 0 1 |
As shown in the table, any digit of the decimal system can be written as a sum of 8, 4, 2, 1. For example: –
7 can be written as 4 + 2 + 1, so its BCD representation is 0111.
Features of BCD Codes
Here are some of the features of BCD listed.
- BCD is an efficient and faster way of representing numbers as we use the positional value system and for any number, we show it as an addition of those positional values.
- In BCD, if we have to include a bit’s positional value, we encode it with 1.
- BCD code uses the binary weights of 8-4-2-1 as positional values.
- To represent a decimal number, either 4-bits or 8-bits can be used. Using 4-bits is known as packed BCD representation and 8-bits is known as unpacked BCD representation.
- BCD numbers are decimal numbers only.
- It is different from decimal to binary conversion and also different from hex-to-binary conversion as we only represent 0-9 digits and not till 16.
Conversion of Decimal to BCD
To convert a number from decimal to BCD, we write down each of the decimal digits as its equivalent BCD code separately. It is to be kept in mind, this is not equivalent to decimal to binary conversion.
For example,
- (526)10 can be written in BCD as (0101 0010 0110)
5 —-> 0101 2 —-> 0010 6 —–> 0110 - (22)10 can be written in BCD as (0010 0010)
2 ——> 0010 - (784)10 can be written in BCD as (0111 1000 0100)
7 —-> 0111 8—> 1000 4—-> 0100
Conversion of BCD to Decimal
To convert a BCD code into decimal, we make groups of four bits beginning from LSB and write down the equivalent decimal digits for each group individually. Some points to note are: –
- This can only be done if the groups range between 0000-1001.
- If even one group does not belong to this, the number is considered an invalid BCD number.
- Also note, BCD to decimal conversion will give different results compared to binary to decimal conversion of the same number.
For example,
- (01101001) BCD code in decimal is written as (69)10
0110 —-> 6 1001 —-> 9 - (00010101) BCD code in decimal is written as (15)10
0001 —–> 1 0101 ——> 5 - (11000101) is an invalid BCD number as 1100 has no decimal equivalent digit.
Interconversion of BCD and Binary Numbers
Binary numbers can be converted into BCD by the following steps: –
- First, convert the binary number into decimal using positional values.
- Then convert the decimal number into its BCD equivalent.
For example, (11000101)2 in decimal is 1 x 27 + 1 x 26 + 1 x 22 + 1 x 20 = (197)10
197 in BCD is written as (0001 1001 0111)
BCD numbers can be converted into binary by the following steps: –
- First, convert the BCD number into decimal by making groups of 4-bits and writing its equivalent.
- Then convert the decimal number into binary using repeated division by 2 or by writing it as a sum of multiples of 2.
For example, (0101 0110) BCD code can be written in decimal as (56)10
56 in binary can be given as (32 + 16 + 8)
= (1 x 25 + 1 x 24 + 1 x 23)
= (111000)2
Advantages of BCD
- BCD includes decimal digits 0 to 9 in 4-bit binary representation. So, only ten 4-bit binary codes need to be remembered.
- BCD is the fastest system to convert decimal into binary as compared to pure binary number system because it includes only ten 4-bit binary codes.
- BCD is used in seven segment display which is a very important device in our daily life. The circuit used for this is BCD to seven segment decoders. It takes input as BCD and lights corresponding LEDs to display a decimal digit.
Disadvantages of BCD
The disadvantages of BCD are explained below:
- It requires four bits to represent a decimal number whereas in pure binary system decimal number can be represented by less number of bits. So, BCD is less efficient as compared to pure binary system.
- Arithmetic calculations with BCD number is complex and completely different from other number systems. So, it requires separate techniques and rules for computations.
- Frequently errors occur because only ten 4-bit combinations are used out of 16. While solving for Boolean expressions using BCD a large number of “don’t care” cases get involved.
Advantages of Binary Coding System
- It has a fixed base ‘2’ which specifies that this coding system uses only two digits to represent numbers. So, it is very simple to operate and learn.
- As this coding system uses only two digits, probability of errors is less and computations are fast.
- This is very much suitable for digital communication over long distances as data packets are sent bit by bit.
- This coding system is very much helpful to understand about computers and functions inside microprocessors.
Morse Code and Its Applications
Morse code and its applications are explained below:
- It is a non-binary coding system and it uses dots and dashes to represent its code separated by spaces. It is named after Samuel Morse, who invented Morse Coding technique in 1837.
- It is mostly used in telecommunication systems for radio transmission. It separates spark transmission from radio transmission. It is also popularly used for secret data communication.
- Morse code is very easy to generate. It can be generated only by blinking of eyes or by an ON-OFF switch. It also uses very low amount of power during transmission of messages over long distances.
Differences Between BCD and Morse Code
The differences between BCD and Morse code are listed below:
Parameters | BCD (Binary Coded Decimal) | Morse code |
---|---|---|
Classification | It is a binary coding system. | It is a non-binary coding system. |
Symbols | It uses ten decimal digits in 4-bit binary form. | It uses dots and dashes for coding. |
Origin | It was developed by International Business Machines Corporations (IBM). | It is named after Samuel Morse, who invented Morse Coding technique in 1837. |
Uses | BCD is commonly used in electronic devices where numeric values are to be displayed. | It is mostly used in telecommunication systems. |
Example | ‘7’ in BCD is represented as 0111. | ‘A’ in Morse code is represented as • |
Baudot Coding System and Its Evolution
Baudot coding system is explained in the points below:
- It is an alphanumeric classification of codes. It is a 5-bit coding system which uses crosses and dots for coding. It can generate 32 combinations of codes where each combination can represent a single character.
- It was developed by Emile Baudot in 1870. In the 20th century this code was popularly used for telegraphy system where 5-bit signals were generated by ON-OFF switches.
- Modern Baudot coding system has the ability to generate 128 possible combinations by using seven bits of code. Sometimes one extra bit is added for error detection.
Other Weighted Codes
Apart from BCD (8-4-2-1) code, we have other weighted codes like 2-4-2-1 {two-four-two-one} and 8-4-(-2)-(-1) {eight-four-minus two-minus one}. The following table shows the other two weighted codes.
Decimal Numbers | 2-4-2-1 | 8 – 4 – (-2) – (-1) |
---|---|---|
0 | 0 0 0 0 | 0 0 0 0 |
1 | 0 0 0 1 | 0111 |
2 | 1 0 0 0 | 0110 |
3 | 0111 | 0101 |
4 | 0110 | 0100 |
5 | 0101 | 1011 |
6 | 1 1 0 0 | 1010 |
7 | 0 1 1 1 | 1001 |
8 | 1 1 1 0 | 1000 |
9 | 1 1 1 1 | 1111 |
As shown in the table,
- Both the codes are self-complementary as the codes for 0 & 9, 1 & 8, 2 & 7, etc. are complementary to each other.
- The positional values are selected such that the sum of positional values in each of these two codes result into 9. (2 + 2 + 4 + 1 = 9 and 8 + 4 – 2 – 1 = 9)
- These codes are not sequential as the code for a digit cannot be obtained by adding one to its previous code.
Comparison Between BCD and Other Weighted Codes
Here is a table showing the comparison between BCD and the other two weighted codes.
Parameters | BCD | 2-4-2-1 | 8 – 4 – (-2) -(-1) |
---|---|---|---|
Weighted | It is a weighted code. | It is a weighted code. | It is a weighted code. |
Self-complementary | It is not self-complementary | It is self-complementary. | It is self-complementary. |
Sequential | It is sequential. | It is not sequential | It is not sequential |
Key Points to Remember
Here are the key points to remember in “Binary Coded Decimal (BCD)”.
- Codes in the number system are groups of symbols used to represent numbers, words, and characters, often for secure data communication.
- Codes can be classified into weighted/unweighted, sequential/non-sequential, and self-complementary/non-self-complementary codes.
- BCD stands for Binary Coded Decimal. It is used to encode the decimal digits from 0-9 as four-binary bits in terms of its positional values of 8-4-2-1.
- For weighted code, the sum of positional values which have 1 as its encoding will give the equivalent decimal digit.
- BCD codes can be interconverted into decimal and binary.
- BCD simplifies decimal representation and is fast for conversions but is less efficient in bit usage and has complex arithmetic rules.
- The binary coding system (base 2) is simple, reduces error probability, and is suitable for digital communication and microprocessor operations.
- Morse code is a non-binary coding system using dots and dashes, primarily used in telecommunications and easy to generate for secret communications.
- BCD is not self-complementary while codes like 2-4-2-1 and 8-4-(-2)-(-1) are self-complementary, highlighting differences in properties and applications among various weighted codes.