Parity bit

Parity bits are a super simple way to check for an error when transferring data over a network / cable.

THe idea is that we add an extra bit to the end of our data, which is called the parity bit.

What does the parity bit store?

This parity bit will tell the receiver whether the number of 1s in the group of data is even or odd, through a single bit in each ‘group’ of data.

For example, if we have the data 1010, we have two 1s, which is an even number. So, depending on our convention, we could set the parity bit to 0 to indicate that the number of 1s is even. If we had the data 1011, we have three 1s, which is an odd number. So, we could set the parity bit to 1 to indicate that the number of 1s is odd.

How does the receiver use the parity bit?

When the receiver gets the data, it can count the number of 1s in the data and compare it to the parity bit. If the parity bit says there should be an even number of 1s, but the receiver counts an odd number, then it knows that something went wrong during the transmission of the data.

It can ask the sender to send it again.

Benefits of parity bits

Downsides of parity bits

Even parity

In even parity, the parity bit is a 0 if the number of 1s in the data is even, and a 1 if the number of 1s is odd.

Odd parity

In odd parity, the parity bit is a 1 if the number of 1s in the data is even, and a 0 if the number of 1s is odd.