Error Detection
Data Transmission
A check digit is an extra digit appended at the right-hand side of a numerical code, computed from the other digits via an agreed algorithm, so that the receiver can spot data-entry errors.
Check digits are different from the methods above: they protect against errors in numerical data entry by humans, not against transmission errors. The same maths is used, but the use case is different.
Typical errors that check digits catch:
- Single-digit error: a wrong digit was typed (e.g. 7 instead of 1).
- Transposition error: two adjacent digits were swapped (e.g. 21 instead of 12).
- Omitted or extra digits: a digit was missed out or one was added by mistake.
- Phonetic errors: confusion between digits that sound similar over the phone (e.g. 13 vs 30).
How a check digit works
- The other digits in the number are run through the check-digit algorithm.
- The algorithm produces a single digit.
- This digit is appended to the end of the number.
- Whenever the number is entered or scanned later, the algorithm is re-run on the digits and the result is compared with the final digit.
- If they match, the number is treated as valid. If not, the number is rejected.
Common uses of check digits
- ISBN-10 book identifiers: every printed book carries a 10-digit ISBN whose final digit is a check digit. An ISBN-10 is valid if (1 × digit₁ + 2 × digit₂ + … + 10 × digit₁₀) is divisible by 11.
- Barcodes (EAN-13, 13 digits; UPC-A, 12 digits): product codes used on supermarket items, ending in a check digit. The barcode scanner re-calculates the check digit from the bars it has read; if the calculated digit does not match the printed one, the scanner refuses the read and beeps for a retry.
- Bank card numbers (Luhn check)
- National identity numbers in many countries
- Vehicle Identification Numbers (VINs) on cars
Exam tip
Explaining how a check digit checks a scanned barcode
A four-mark question asked how a barcode scanner's check digit catches input errors. The scheme listed six separate points and credited any four: the check digit is calculated from the other digits of the barcode; using an algorithm (naming one, such as modulo 11, counts); it is added to the barcode; once the barcode is scanned the digit is recalculated from the digits read; using the same algorithm; and if the result differs from the stored digit, an error has occurred (or, if they agree, no error). Recalculating and comparing are separate points, so keep them as separate sentences.
Quick check
4 short questions on this note. See what has stuck, and where to look if something hasn't.