Tech●●●●●Difficulty 3 of 5

How can one extra digit catch a typo or a flipped bit?

A mathematician got so fed up with his computer wrecking his weekend jobs that he taught it to fix its own mistakes.

▶ Start the story

By adding a little redundancy: extra information the receiver can check against the rest. The simplest version is the parity bit. Before sending a group of bits, you add one more bit chosen so that the total number of 1s is even. If a single bit flips on the way, the count becomes odd and the receiver knows something went wrong. Your credit card number plays a similar trick: its last digit is a check digit computed with the Luhn algorithm, which catches every single mistyped digit and almost every swap of two neighbouring digits.

Detecting isn't fixing, though. Parity can't tell you which bit is wrong, so the data has to be sent again, and if two bits flip, the count looks fine and the error slips through.

Detecting versus correcting

One parity bit

  • Adds a single extra bit
  • Spots any single flipped bit
  • Misses two flips
  • Can't say which bit: resend everything

Hamming(7,4)

  • Adds three parity bits to four data bits
  • Checks overlap
  • Failed checks point to the bad bit
  • Flips it back, no resend needed

That limitation drove Richard Hamming mad. In the late 1940s at Bell Labs, his relay computer would stop and flash its lights for an operator when it found an error, but on weekends, with nobody there, it simply abandoned his job and moved on. "If the machine can detect an error," he fumed, "why can't it locate the position of the error and correct it?" His answer, the Hamming code published in 1950, uses several overlapping parity bits so that the pattern of failed checks points straight at the broken bit. It still protects computer memory today.

Quiz me

0/3

  1. 1.A parity bit is set so the number of 1s is even. Why does it miss an error where two bits flip?
  2. 2.What made Hamming's code able to correct an error, not just detect it?
  3. 3.How can a website instantly spot a mistyped credit card number?

Recap

One parity bit can tell you that something broke; several overlapping parity bits can tell you where.

Surprising fact · A credit card's last digit is a check digit that catches every single mistyped digit.

Sources (3)

No source, no claim. Every fact in this lesson (21 claims) cites at least one of these.

  1. [1]Error detection and correction · Wikipedia
  2. [2]Hamming code · Wikipedia
  3. [3]Luhn algorithm · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗