Understanding the Parity Bit
A parity bit is a single extra bit appended to a group of data bits — a byte, a word, or any fixed-size block — so that the total number of 1-bits in the combined string always matches a chosen convention: always even (even parity) or always odd (odd parity). It is the oldest and simplest error-detecting code in digital systems, used in serial links like RS-232, early parity-checked RAM, and simple checksums where a lightweight sanity check matters more than correcting the error.
The formula
The parity bit is computed as the exclusive-OR (XOR, written ⊕) of every data bit:
- XOR of data bits: x = b1 ⊕ b2 ⊕ ... ⊕ bn. This equals 1 if the data contains an odd number of 1s, and 0 if it contains an even number of 1s.
- Even parity bit: p = x. Appending p makes the total count of 1s (data + parity) even, because a data string with an odd number of 1s gets a 1 added (making it even), and a string with an even number of 1s gets a 0 added (staying even).
- Odd parity bit: p = NOT(x) = 1 ⊕ x. This forces the total count of 1s to always be odd instead.
Worked example
Take the 7-bit data string 1011001. Counting the 1s gives four (positions 1, 3, 4, and 7), which is already even.
- Even parity: since the data already has an even number of 1s, the parity bit is 0. The transmitted codeword becomes 10110010, still four 1s — even.
- Odd parity: the parity bit must flip that to odd, so it is 1. The codeword becomes 10110011, five 1s — odd.
The receiver repeats the same count on the full codeword. If the result does not match the agreed parity (even or odd), the receiver knows at least one bit changed in transit and can request a retransmission.
What a parity bit can and cannot catch
A single parity bit reliably flags any odd number of bit flips — 1, 3, 5, and so on — because each flip toggles the overall 1-count's parity. It is blind to an even number of flips (2, 4, ...), since those cancel out and leave the count's parity unchanged. It also cannot say which bit was corrupted or fix it — only that something disagrees with the expected total. Systems that need to locate or correct errors use stronger codes such as Hamming codes (single-error-correcting, double-error-detecting) or a CRC (cyclic redundancy check), both of which use more bits than a single parity bit but catch far more error patterns.