# Error-Detecting Code and Parity

In this tutorial, we will learn about error-detecting code and parity with the help of examples. By Saurabh Gupta Last updated : May 10, 2023

## What are Error-Detecting Codes?

A group of bits is known as words, and these words move as an entity from one block to another in the digital system. While moving from one part to another within the system via transmission media, the bits within the word can get altered/distorted due to external factors, whom we call Noise. Because digital systems need to be accurate to the digit, an error can pose a serious threat. So, several error detecting methods are introduced to find these incorrect bits in the words, which can be corrected and after detection and should be retransmitted.

## Error Detection Technique: Parity

The simplest technique for detecting an error in a word is adding an extra bit in the group of bits, this extra bit is known as the parity bit.

There are two types of parity which we consider for error detection purposes which are ODD parity and EVEN parity. In odd parity, 0 or 1 parity bit is added to the group of bits such that the total number of 1 bit including the parity bit in word remains odd in number. Similarly, in even parity, 0 or 1 bit is added in the group of bits such that total no. of 1 bit including the parity bit in the word remains even in number.

Given below is a table which contains message bit of 4 bits and the parity bit in odd and even parity cases,

Word of 4 bits Parity Bit(Odd) Word of 4 bits Parity Bit(Even)
0000 1 0000 0
0001 0 0001 1
0010000101
0011100110
0100001001
0101101010
1100111000
0111001111
1000010001
1001110010
1010010100
............
............

A parity checker circuit is set up on the receiving side which generates an error whenever an odd number of 1's occurs in case of even parity and an even number of 1's occurs in case of odd parity system.

Generally, odd parity is used more often than even parity because even parity does not detect the situation where all 0's is created by a short circuit or other fault condition.

### Example 1: In even-parity system, which of the following words contain an error?

1. 0010100011
2. 1010001010
3. 0010000110

In an even-parity system, total number of 1’s should be even. So,

1. 0010100011, contains 4 one bit which is even. Thus, it has no errors.
2. 1011101010, contains 6 one bit which is even. Thus, it has no errors.
3. 0010000110, contains 3 one bit which is odd. Thus, this word has an error.

### Example 2: In odd-parity system, which of the following words contain an error?

1. 1011101111
2. 1011000011
3. 1011110110

In an odd-parity system, total number of 1’s should be odd. So,

1. 1011101111, contains 8 one bit which is even. Thus, it has an error.
2. 1011000011, contains 5 one bit which is odd. Thus, it has no errors.
3. 1011110110, contains 7 one bit which is odd. Thus, it has no errors.