What is a Parity Bit?

Introduction to Quantum Computing

Parity

A parity bit is a bit added to a string of binary code.  They are a form of error detecting code. Parity bits are generally applied to the smallest units of a communication protocol.

The parity bit ensures that the total number of 1-bits in the string is even or odd. Thus, there are two types of parity bits: even and odd.

For even parity, the occurrences of bits whose value is 1 are counted. If that count is odd, the parity bit value is set to 1, making the total count of occurrences of 1s in the whole set (including the parity bit) an even number. If the count of 1s in a given set of bits is already even, the parity bit's value is 0. 

For odd parity, the coding is reversed. For a given set of bits, if the count of bits with a value of 1 is even, the parity bit value is set to 1 making the total count of 1s in the whole set (including the parity bit) an odd number. If the count of bits with a value of 1 is odd, the count is already odd so the parity bit's value is 0.

So, parity is a mathematical term indicating if two things are the same or if they are different.  For example, if two data bits labeled b1 and b2 are the same, then they have a parity equal to 0. If the two data bits are different, then they have a parity of 1. Said differently, the parity of two data bits can be described using a third “parity bit" labeled bp, which stores value 0 when the data bits are the same, and it stores the value of 1 when they are different.

b1b2 = 00 → bp = 0
b1b2 = 01 → bp = 1
b1b2 = 10 → bp = 1
b1b2 = 11 → bp = 0