BCD Code, Excess-3 Code, 2421 Codes, Gray Code (2024)

This article was written and is being distributed in order to provide a description of the four distinct sorts of codes, which are

  1. Binary-coded decimal (BCD) code
  2. Excess-3 code
  3. 2421 code
  4. Gray code

Now that we have everything out of the way, let's go through each of these four codes one at a time, beginning with the "BCD code."

BCD Code

The BCD code is the most straightforward method for employing binary numbers to represent decimal numbers.

In BCD code, a decimal number is represented by a binary value that has four bits.

If a decimal number has two or more digits, then each of those digits is individually represented by its corresponding binary representation thathas four bits. As an illustration, the number (278)10 written in BCD appears as seen in the following picture:

BCD Code, Excess-3 Code, 2421 Codes, Gray Code (1)

Therefore, we can say that the number 278 in binary is represented as 0010 0111 1000 or (278)10 = 0010 0111 1000.

BCD is a weighted code, which means that the weights of the binary bits that represent individual digits are 8, 4, and 1, respectively.Subtraction on modern computers is performed using complements, and it is difficult to construct complements when integers are representedusing BCD codes.

However, we can also use a 4-bit binary value, which is called "BCD 8421 encoding." I included the following table for your understanding.

Decimal digit BCD
8 4 2 1
0 0 0 0 0
1 0 0 0 1
2 0 0 2 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

If you're not sure how the data is entering the table, let me explain briefly. To write the "8421" code for the matching "decimal digit," dividethe decimal digit so that it comprises only 8, 4, 2, and 1, the sum of which is the decimal digit itself. For example, if 9 is divided into two digits, 8 and 1, there will be 1 in place of these two digits, and if we add 8 and 1, we will obtain 9. Another example is the number 7, which can be divided into three digits: 4, 2, and 1. As a result, we must write 1 under 4, 2, and 1.

If we want to convert 35 to BCD-8421 code, we can do so by remembering that 3 is equivalent to 0011, and 5 is equivalent to 1010, so 35 will be00110101 in BCD-8421.

Excess-3 Code

In the excess-3 code, 3 is added to each individual digit of a decimal number, and then the binary equivalent is written. For example, the code(278)10 in excess-3 is represented by 0101101011. This code is not weighted.

Because 3 is added, the decimal digit "-3" equals "0000" in "Excess-3". For your understanding, I included the following table, which consists ofdecimal digits and their corresponding excess-3 codes.

Decimal Excess-3
-3 0000
-2 0001
-1 0010
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100
10 1101
11 1110
12 1111

If we take the example of converting 9 to "excess-3" code, Then, since 9 is equivalent to 1001, adding 3 gives 1100. Therefore, the decimal digit9 is equivalent to 1100 in "excess-3." If you are still having trouble understanding it, let's take a look at the following process:

 1001 (9)+ 0011 (3)---------- 1100

That is, the binary equivalent of 9 is 1001, but since we need to add the 3 in "excess-3," we must add 0011 (the equivalent value of 3) to 1001,which is 1100.

Other names of the "Excess-3" code are "3-excess" and "10-excess-3."

2421 Code

The 2421 code, which is also known as the "Aiken code," is another BCD code. It is a code that has been weighed. For example, 6 is 1100, and 3 is0011.

The following table, which I have included in this section, is provided for your understanding.

Decimal digit 2 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 1 0 1 1
6 1 1 0 0
7 1 1 0 1
8 1 1 1 0
9 1 1 1 1

I don't believe this table requires any further explanation after describing the "BCD-8421 code" using the table included in the "BCD code"section above. This table works similarly to that one.

GRAY Code

The gray code is a binary code. The binary bits are arranged in such a way that only one binary bit changes at a time when we change fromany number to the next.

Gray code is reflected code. This code is used in shaft encodes, which indicate the angular position of a shaft in digital form. Shaftposition encoder discs are used as sensors. It is not a weighted code. Gray code can be constructed using the following properties:

  • A 1-bit gray code has two code words to represent the decimal numbers 0 and 1, respectively.
  • A n-bit gray code will have the first 2n-1 gray codes for n-1 bits written in order with a leading 0 appended.
  • The last 2n-1 gray code will be equal to the gray code words of an (n-1) bit gray code, written in reverse order (assuming a mirror is placed between the first 2n-1 and last 2n-1 gray codes) with a leading 1 appended.

Example

The following table provides an illustration of how each of the four distinct types of code can be transformed into the others.

Decimal No.BCD (8421)Excess-3 Code2421 CodeGray Code
00000001100000000
10001010000010001
20010010100100011
30011011000110010
40100011101000110
50101100001010111
60110100111000101
70111101011010100
81000101111101100
91001110011111101
100001 000011011111
110001 000111101110
120001 001011111010
130001 00111011
140001 01001001
150001 01011000

Computer Fundamentals Quiz

« Previous TutorialNext Tutorial »


Liked this post? Share it!

BCD Code, Excess-3 Code, 2421 Codes, Gray Code (2024)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 6127

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.