Computer science
Parity bits & error detection
A single extra bit reveals whether something went wrong along the way.
What you need first
When you send a voice message or stream a video, billions of bits race through cables and radio waves. Sometimes a bit flips: a 1 becomes a 0, for example because of interference. So how does your phone know the message still arrived intact? The trick behind it is surprisingly simple, and you use it every day without noticing.
One bit as a guard
The idea is called a parity bit: before the data is sent, the sender counts the ones in the bit sequence. If the count is odd, it appends a 1, if it is already even, it appends a 0. That way the number of ones always ends up even, and this convention is called even parity. The receiver simply counts again: if it finds an odd number of ones, at least one bit must have flipped along the way, and it asks for the data again. Some systems agree on the opposite, odd parity. All that matters is that sender and receiver follow the same rule.
10010110
10010110 = 128 + 16 + 4 + 2 = 150
Check digits in everyday life
The same idea hides in many numbers you know: the last digit of an ISBN on a book or the check digits in an IBAN are calculated from the other digits. If you mistype while making a transfer, the calculation no longer works out, and the banking app complains immediately, before money goes to the wrong person. One digit that exists purely for checking, just like the parity bit.
The limits of the trick
The parity bit is powerful but not almighty. If two bits flip at the same time, the number of ones is even again, and the error goes unnoticed. Also, the parity bit only tells you that an error happened, not where. There are cleverer schemes with several check bits for both problems, but they all build on the same core idea: send extra information along that lets you verify the data.
Exercises
0 of 6 solvedTime to try it yourself. You can't break anything, every attempt counts.
What is a parity bit for?
How many ones does the bit sequence 1011 contain?
Which parity bit (0 or 1) do you append to 1011 so the number of ones becomes even?
Put the steps of error detection with a parity bit in the correct order.
- 1It appends a suitable parity bit so the count becomes even.
- 2The sender counts the ones in the bit sequence.
- 3The bit sequence is sent over cable or radio.
- 4The receiver counts the ones again and checks whether the count is even.
Which parity bit (0 or 1) belongs on the bit sequence 1001 with even parity?
With even parity the parity bit is chosen so that the number of ones always ends up ….
Where this leads