Wires are noisy places. A spike of electrical interference can flip a single bit — turning a 0 into a 1 — and now the balance you sent as £100 arrives as £228. Computers cannot stop errors happening, but they can be clever enough to notice that something changed, and sometimes even work out which bit changed. That is the job of error detection and correction.
Parity bit (even or odd)
A byte is given one extra parity bit. Under even parity the total number of 1s (including the parity bit) must be even; under odd parity it must be odd. The sender sets the parity bit to make the count match; the receiver recounts. If the count is wrong, an error is detected.
| Seven data bits | Number of 1s | Even-parity bit | Byte sent |
|---|---|---|---|
| 0110100 | 3 (odd) | 1 | 10110100 |
| 1001101 | 4 (even) | 0 | 01001101 |
In the first row there are three 1s, which is odd, so the even-parity bit must be 1 to make four 1s in total (even). In the second row there are already four 1s, so the parity bit is 0.
Parity block check
Bytes are stacked in a block, with a parity bit on every row and an extra parity byte at the bottom giving the parity of every column. A single flipped bit makes exactly one row and one column fail their parity — and the bit at that crossing point is the culprit, so it can be corrected, not just detected.
Other methods
- Checksum — a value is calculated from the data and sent with it. The receiver recalculates; if the two differ, an error occurred.
- Echo check — the receiver sends the data back to the sender, who compares it with the original. It can detect an error but cannot tell if it happened on the way out or the way back.
- Check digit — a final digit calculated from the others (as on an ISBN or a barcode). If entered data does not produce the same check digit, an error is caught at input.
- Automatic Repeat reQuest (ARQ) — the receiver checks each packet; if it is faulty or no acknowledgement arrives before a timeout, the sender is asked to resend it.
Count the 1s: 0,1,1,0,1,0,0 has three 1s (odd). Even parity needs an even total, so the parity bit must be 1 (making four 1s). If the parity bit is placed on the left: 1 0110100 → byte 10110100.
Memory hook: "Row meets column" pinpoints the bad bit in a parity block. And ARQ = Ask to Resend, Quickly.