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, UPC): 13-digit 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
Example — A 4-digit code is followed by a check digit. The algorithm is "sum of all four digits, take the last digit (modulo 10)". A new code 7-2-3-? needs a check digit.
- Sum of the four data digits: 7 + 2 + 3 + 0 = 12. (We add the placeholder 0 for the unknown check digit.)
- Actually we want the check digit on its own. Sum just the first three: 7 + 2 + 3 = 12.
- Last digit of 12 = 2.
- Full code: 7-2-3-2.
If someone types the code as 7-3-2-2 (swapping the 2 and 3), the receiver:
- Re-calculates: 7 + 3 + 2 = 12, last digit = 2. The same check digit comes out, so this naive algorithm fails to catch the transposition.
A real check-digit algorithm uses weighted sums (each position multiplied by a different number) so that swapping two digits produces a different total. That is why ISBN-10 uses weights 1 through 10 instead of all 1s.