Types of Binary Codes- 8421,2421,5211, Excess-3, Gray

Binary codes are basically ways of representing information using binary digits, i.e., 0s and 1s. In digital electronics, various binary codes, such as BCD, 2421,5211, Ex-3, Gray, and ASCII, are used to represent text and numeric data.

Types of Binary Codes

The codes can be majorly classified into the following two categories:

  • Weighted Codes
    • BCD Code or 8421 Code
    • 2421 Code
    • 5211 Code
  • Non-weighted Codes
    • Excess-3 Code
    • Gray Code

Let us now discuss these codes in detail.

types-of-binary-codes

(1). Weighted Codes

The type of binary code in which the value of the digit depends on its position in the number is called weighted code. Hence, in weighted codes, each position in a binary number has a specific weight associated with it.

example-of-binary-codes

For example, consider a given binary number (1001), then

weighted-binary-codes

Hence, in this binary number, the positional weight of the ‘1’ at the LSB position is ‘1’, whereas the positional value of the 1 at the MSB position is ‘8’.

Now, let us discuss some examples of weight codes.

(a). BCD Code or 8421 Code:

BCD (Binary Coded Decimal) code is a binary code used to represent the decimal numbers, i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 in Binary form. The decimal numbers and their BCD codes are represented in the following table. In the case of BCD codes, each decimal digit is expressed as a group of 4 bits.

Since it is a weighted code, the 4 Bits can be expressed in terms of their place value from left to right as 8421, i.e.,

BCD Code Table:

Decimal NumberBCD Code
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001

The 8421 BCD code is also known as sequential code because two adjacent binary codes differ by one digit.

(b). 2421 Code:

Similar to the BCD or 8421 code, the 2421 code is another type of weighted code used in digital systems. This code measures the positional weights as 2 4 2 1.

The following table gives the decimal numbers and their corresponding 2421 codes.

2421 Code Table:

Decimal NumberBCD Code
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001

The 8421 BCD code is also known as sequential code because two adjacent binary codes differ by one digit only in this type of binary code.

(c). 5211 Code:

The 5211 code is another 4-bit weighted binary code in which the positional weight is expressed as 5, 2, 1, and 1 from left to right.

The following table shows the decimal digits and their corresponding 5211 codes.

5211 Code Table:

Decimal Number5211 Code
00000
10001
20011
30101
40111
51000
61010
71100
81110
91111

Note – From the tables of the 2421 code and 5211 code, it is clear that the binary code for decimal 9 is the complement of the binary code for decimal 0; similarly, the binary code or decimal 8 is the complement of the binary code for decimal 1, and so on. Such codes are referred to as Reflective Codes.

(2). Non-Weighted Codes

In some binary codes, there is no relation between the value of the digit and its position in the number; such codes are termed non-weighted binary codes. The non-weighted codes are used in special applications where the positional weight is not crucial. Common examples of non-weighted binary codes include Excess-3 codes and gray codes.

Now, let us discuss the Excess-3 codes and gray codes in detail.

(a). Excess-3 Codes:

Excess-3 code, also called XS-3 code or Ex-3 code, is a type of non-weighted binary code. The Ex-3 code is a 4-bit code that is obtained by adding 3 to a BCD 8421 code.

For example, the Ex-3 code for 3 (0011) in the BCD code is equal to 3 (0110) in the Excess-3 code.

Now, the number 6 is converted into BCD(8421 code)

Therefore, the excess-3 code of decimal number 3 is 0110.

The decimal numbers and their corresponding Ex-3 codes are listed in the following table.

Excess-3 Code Table:

Decimal DigitBCD CodeExcess-3 Code
000000011
100010100
200100101
300110110
401000111
501011000
601101001
701111010
810001011
910011100
Example- Excess-3 code of (175.27)10 is;

Excess-3 code of (175.27)10 is (010010101000.00111010).

(b). Gray Code:

The gray code is another non-weighted binary code in which one bit differs from the preceding number. It is a type of reflective binary code, as in this code, the two successive codes differ by only one binary digit.

For example, the decimal numbers 8 and 9 are represented in gray code as 1100 and 1101, respectively. These two codes differ only in a single position or a single bit, that is, the first position from the right. For this reason, the gray code is also called Unit Distance Code. Similar to Ex-3 codes, the gray codes are also used in special applications in digital electronics.

The table representing decimal digits and their corresponding gray codes is given below.

Decimal NumbersGray Code
00000
10001
20011
30010
40110
50111
60101
70100
81100
91101
101111
111110
121010
131011
141001
151000

Advantages of Binary Codes

  • Binary codes are simple, and they consist of only two digits, 0 and 1. The codes can be easily implemented in electronic circuits with faster processing.
  • The digital electronics circuit functions with on/off states, and binary is the natural language of computers. Therefore, the binary system( 0 and 1 states) is a perfect fit for representing these states.
  • The redundancy in the binary codes can be done to detect errors in data storage and communication.
  • Electronic systems and computers do binary operations, such as AND, OR, and NOT, which form the basis of digital logic. These codes are very simple to perform all these logic operations.
  • Digital data can be stored more efficiently in binary format. These codes need less space on storage devices—the codes best fit where space is a critical factor.
  • Binary arithmetic operation is much simpler than decimal arithmetic because the binary operation has only two digits, 0 and 1. The use of binary codes simplifies the design of arithmetic logic units (ALUs) in processors.
  • Binary is a universal language in digital electronics, and therefore, the different devices operating on this system can be easily interfaced.
  • These codes are useful for a machine language, the lowest-level programming language understood by computers and digital electronics.

Conclusion

In conclusion, binary codes play a vital role in digital electronics. They represent information in binary forms that digital systems like computers can understand and process. In this article, we have explained all the commonly used types of binary codes in detail with the help of examples.

Leave a Comment