Parity Bit
Errors in binary communication refers to situations where the message received differs from the message intended to be transmitted. This can occur for various reasons, such as poor signal integrity, noise, or system failures. The errors can lead to incorrect interpretations of the message and affect the accuracy and reliability of a digital signal communication. One solution to reducing binary communication errors is the use of a parity bit.
In this article:
What is Parity Bit?
A parity bit, also referred to as parity check, is an extra bit added to a set of binary data bits for the purpose of error detection during data transmission. The parity bit is used to check if the number of 1s in a data string is even or odd, resulting in two types: even parity bit and odd parity bit.
Binary Errors
An error in binary communication occurs when a 1 unexpectedly turns into a 0 or vice versa.
Learn more: Serial data communication standard RS232
Even Parity
In an even parity system, the parity bit is set to either 1 or 0 so that the total number of 1bits, including the parity bit, becomes an even number.
How to calculate even parity
If the number of 1s in the data string is odd, the parity bit is set to 1 to ensure that the overall number of 1s, including the parity bit, is even. If the number of 1s in the data string is already even, the parity bit is set to 0.
Odd Parity
In an odd parity system, the parity bit is set to either 1 or 0 so that the total number of 1bits, including the parity bit, becomes an odd number.
How to calculate odd parity
If the number of 1s in the data string is even, the parity bit is set to 1 to ensure that the overall number of 1s, including the parity bit, is odd. If the number of 1s in the data string is already odd, the parity bit is set to 0.
Parity Bit Examples
Data string of 7 bits

Number of 1bits  8 bits including the parity bit  

even parity  odd parity  
0000000  0  00000000  00000001 
1100001  3  11000011  11000010 
1100101  4  11001010  11001011 
1111111  7  11111111  11111110 
Parity bit checking is commonly used in the transmission of ASCII characters, where the 8th bit is reserved as a parity bit while the remaining 7 bits are used to encode the character.
How Parity Bit Works
Before transmitting data, both the transmitter and receiver must agree on odd or even parity. Before sending each data packet (string of bits), the sender calculates its parity bit (0 or 1) to ensure that it matches the agreed parity (odd or even). Upon receipt, the receiver checks the received data's parity against the expected parity. If they don't match, it indicates an error, and the data can be discarded or corrected by requesting a retransmission.
The parity bit is only used to help detect errors, but it lacks the ability to rectify any errors because it cannot identify the specific corrupted bit. Thus, the only option to fix errors is to discard the entire data string and request retransmission from the sender.
Parity bit position
While there is no set rule for the position of the parity bit, it is commonly added at the end of the binary string message by convention.
Error Detection
Parity checking at the receiver can spot errors by comparing the received signal's parity to the expected parity. If there's a mismatch, the receiver can request a retransmission from the transmitter.
Detecting if the number of 1s in a binary data string is even or odd can be calculated by the Modulo operator. Modulo, or "mod," is a mathematical operation that finds the remainder when one integer is divided by another. The Modulo operation is represented using the symbol %.
Using Modulo, we can determine if a number is even if it can be divided by 2 with no remainder. On the other hand, if a number leaves a remainder when divided by 2, it is considered odd.
The following C program example illustrates the process of checking parity using modulo:
#include <stdio.h> int main() { unsigned char byte; int num_ones = 0; printf("Enter a byte (in decimal): "); scanf("%hhu", &byte); // Count the number of 1s in the byte for (int i = 0; i < 8; i++) { if ((byte >> i) & 1) { num_ones++; } } // Detect parity with mod 2 and print the parity type. if (num_ones % 2 == 0) { // printf("Even parity\n"); } else { printf("Odd parity\n"); } return 0; }
The program starts by reading in a byte from the user. It then uses a loop to count the number of 1 bits in the byte. This is done by shifting the byte right by each bit position (0 through 7) and checking if the resulting bit is 1. If it is, the count of 1 bits is incremented. Finally, the program checks if the number of 1 bits is even or odd, and prints the appropriate message.
Note that the program uses an unsigned char to store the byte, which is an 8bit integer that can hold values between 0 and 255. The %hhu format specifier is used with scanf() to read in a byte value from the user.
How to add a parity bit
Let's examine an example where we need to transmit the data string 1100101. First, we count the number of 1s in the data string and determine whether the count is even or odd using the mod operator with 2 as the divisor:
(1+1+0+0+1+0+1) mod 2
4 mod 2 = 0
Since 4 divided by 2 has no remainder, the result is 0, indicating that we have an even count of 1s. If we have agreed upon even parity, we append a "0" as the parity bit to the end of the message, resulting in 11001010, which can now be sent. Alternatively, if we have agreed upon odd parity, we reverse the parity bit and append a "1" instead, resulting in 11001011 as the final message that can be transmitted.
Parity Bit Uses
 Error detection: One of the primary uses of parity bits is to detect errors during data transmission.
 Memory storage: Parity bits are also used in computer memory systems to detect errors when data is stored in memory. When data is stored in memory, there is always a risk of errors occurring due to various factors such as electromagnetic interference, hardware faults, etc.
 RAID systems: Parity bit is also used in Redundant Array of Inexpensive Disks (RAID). RAID can also be referred to as "Redundant Array of Independent Drives." RAID systems use multiple disks to store data redundantly and protect against disk failures. They use parity for fault tolerance.
Learn more: EMI (Electromagnetic interference)
Conclusion
In conclusion, the parity bit is a simple but effective error detection mechanism that can help ensure storage and data transmission accuracy. While parity bits are not foolproof and can only detect some errors, they remain useful for many applications in binary data communications.
Latest Blog Posts

Optical Bonding
Many applications, particularly in harsh environments, require specific modifications to their el …Feb 7th 2024 
TN vs IPS  What's The Difference?
In display technologies, TN (Twisted Nematic) and IPS (InPlane Switching) are two terms that oft …Jan 22nd 2024 
MIPI DSI Interface
Imagine a world where devices communicate seamlessly and efficiently, especially with mobile high …Dec 19th 2023