What Is Hamming Code, the Network Technique to Detect Errors and Correct Data

With the increased data transmission and exchange between multiple network devices for information purposes, the probability of an error or damage occurring to the original data bit is highly possible. The network method Hamming Code is used precisely to maintain the issue of error damage and correct the data to a certain extent.

In this article on ‘What Is Hamming Code?’, we will look into the hamming code, along with terms related to hamming code and the working format of the method.

PGP in Cyber Security With Modules From MIT SCC

Your Cyber Security Career Success Starts Here!View Course
PGP  in Cyber Security With Modules From MIT SCC

What Is Hamming Code?

The Hamming Code method is a network technique designed by R.W.Hamming, for damage and error detection during data transmission between multiple network channels.

The Hamming Code method is one of the most effective ways to detect single-data bit errors in the original data at the receiver end. It is not only used for error detection but is also for correcting errors in the data bit.

Let’s look into some important terms related to the hamming code.

Important Terms for Hamming Code

To begin with, the steps involved in the detection and correction of data using hamming code, we need to understand some important terms and expressions, which are:

1. Redundant Bits - These are the extra binary bits added externally into the original data bit to prevent damage to the transmitted data and are also needed to recover the original data.

The expression applied to deduce the redundant value is,

2r >= d+r+1


d - “Data Bits”

r - “Redundant Bits”, r = {1, 2, 3, …….. n}

Example: Assuming the number of data bits is 7, find the number of redundant bits.

  • 2^r >= r+7+1
  • 2^4 >=4+8 [r=4]

The number of redundant bits = 4.

2. Parity Bits - The parity bit is the method to append binary bits to ensure that the total count of 1’s in the original data is even bit or odd. It is also applied to detect errors on the receiver side and correct them.

Types of parity bits:

  • Odd Parity bits - In this parity type, the total number of 1’s in the data bit should be odd in count, then the parity value is 0, and the value is 1.

  • Even Parity bits - In this parity type, the total number of 1’s in the data bit should be even in count; then the parity value is 0, and the value is 1.

Now we will look into step by step working of the hamming code.

Cybersecurity Expert Master's Program

Master the Skills of a Cybersecurity ProfessionalView Course
Cybersecurity Expert Master's Program

Working of Hamming Code

To solve the data bit issue with the hamming code method, some steps need to be followed:

  • Step 1 - The position of the data bits and the number of redundant bits in the original data. The number of redundant bits is deduced from the expression [2^r >= d+r+1].
  • Step 2 - Fill in the data bits and redundant bit, and find the parity bit value using the expression [2^p, where, p - {0,1,2, …… n}].
  • Step 3 - Fill the parity bit obtained in the original data and transmit the data to the receiver side.
  • Step 4 - Check the received data using the parity bit and detect any error in the data, and in case damage is present, use the parity bit value to correct the error.

Next, we will solve an example using hamming code to clarify any doubts regarding the working steps.

Example for Hamming Code


To better understand the working of the hamming code, the following example is to be solved:

The data bit to be transmitted is 1011010, to be solved using the hamming code method.

  • Determining the Number of Redundant Bits and Position in the Data,

The data bits = 7

The redundant bit,

  • 2^r >= d+r+1
  • 2^4 >= 7+4+1
  • 16 >= 12, [So, the value of r = 4.]

Position of the redundant bit, applying the 2^p expression:

  • 2^0 - P1
  • 2^1 - P2
  • 2^2 - P4
  • 2^3 - P8


Applying the data bits in Fig. 1.


Cybersecurity Bootcamp

Certificate and Masterclasses From UCI DCEExplore Now
Cybersecurity Bootcamp

  • Finding the Parity Bits, for ”Even parity bits,”

1. P1 parity bit is deduced by checking all the bits with 1’s in the least significant location.

P1: 1, 3, 5, 7, 9, 11

  • P1 - P1, 0, 1, 1, 1, 1
  • P1 - 0

2. P2 parity bit is deduced by checking all the bits with 1’s in the second significant location.

P2: 2, 3, 6, 7, 10, 11

  • P2 - P2, 0, 0, 1, 0, 1
  • P2 - 0

3. P4 parity bit is deduced by checking all the bits with 1’s in the third significant location.

P4: 4, 5, 6, 7

  • P4 - P4, 1, 0, 1
  • P4 - 0

4. P8 parity bit is deduced by checking all the bits with 1’s in the fourth significant location.

P8: 8, 9, 10, 11

  • P8 - P1, 1, 0, 1
  • P8 - 0

So, the original data to be transmitted to the receiver side is:


  • Error Detecting and Correction of the Data Received,

Assume that during transmission, the data bit at position 7 is changed from 1 to 0. Then by applying the parity bit technique, we can identify the error:


Parity values obtained in the above deduction vary from the originally deduced parity values, proving that an error occurred during data transmission.

To identify the position of the error bit, use the new parity values as,

  • [0+2^2+2^1+2^0]
  • 7, i.e., same as the assumed error position.

To correct the error, simply reverse the error bit to its complement, i.e., for this case, change 0 to 1, to obtain the original data bit.

With the completion of the example for hamming code, we can conclude this article on “Hamming Code for Error Detection and Correction.”

Grab the opportunity to be a part of the MIT CSAIL Professional Programs community and interact with your peers. Attend masterclasses from MIT faculty in our PGP in Cyber Security and expedite your cybersecurity career in no time!


In this article on ‘Hamming Code,’ we looked into information related to the design of the hamming code method, along with the working steps involved in implementing the hamming code technique.

To further improve your knowledge of the hamming code and other network-related technologies, you can refer to Simplilearn’s Cyber Security Expert course. After completing this expert course, you’ll become more proficient in applying network techniques.

If you have any questions about this article on ‘Hamming Code for Error Detection and Correction. Feel free to mention them in the comment section at the bottom of this page. Our expert team will help you solve your queries at the earliest.

About the Author

Anmol KapoorAnmol Kapoor

Anmol is a Research Analyst who aims to become a Data Scientist one day. He enjoys Data Management systems and analysis. You will find him reading a book when he is not working.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.