CalculateQuestion 1 · Apply
Loading…
By the end you can compute a check digit using a weighting rule, test whether a code is valid, and explain what kinds of error a check digit does and does not catch.
When a shop assistant types a long number, one digit can easily go wrong. Compare the typed code with the printed one and the mistake is obvious — but nobody does that in a supermarket queue.
A check digit is the machine's version of that comparison. The last digit of the code is not extra information: it is calculated from all the other digits.
The computer recalculates it and compares, so a changed or swapped digit makes the two disagree.
You meet check digits on barcodes, ISBNs on books, bank account numbers, national insurance numbers and courier tracking codes.
Check digit
A check digit is a digit appended to a code, calculated from the other digits using a fixed rule, so that the receiver can recalculate it and detect errors such as a single mistyped digit or two swapped digits.
Here is one common rule, used by ISBN-10. Each digit is multiplied by a weight, the products are added, and the check digit is whatever makes that total a multiple of 11.
The weights run from 10 down to 2 across the first nine digits, so earlier digits matter more.
Worked example: code 978 030640 (nine digits), check digit missing.
| Digit | 9 | 7 | 8 | 0 | 3 | 0 | 6 | 4 | 0 |
|---|---|---|---|---|---|---|---|---|---|
| Weight | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |
| Product | 90 | 63 | 64 | 0 | 18 | 0 | 24 | 12 | 0 |
The full code is therefore 9780306404. Check it: , a multiple of 11.
If the remainder had been 0, the check digit would be 0. If the answer came out as 10, the usual convention is to write the letter X (Roman numeral for 10), because no single digit can represent 10.
The other common family uses weights of 3 and 1 alternately, starting with 3, and then works modulo 10. This is the idea behind barcodes such as EAN-13.
Worked example: code 509876543, check digit missing.
| Digit | 5 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 |
|---|---|---|---|---|---|---|---|---|---|
| Weight | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 15 | 0 | 27 | 8 | 21 | 6 | 15 | 4 | 9 |
The full code is 5098765435. Checking: the new total is , which is a multiple of 10.
If the subtraction gives 10, the check digit is 0 — you cannot store two digits. The "take the units digit" step handles that: .
A single wrong digit always changes the weighted total, so the remainder changes and the recalculated check digit no longer matches.
In the modulus 11 example, mistyping the seventh digit 6 as 7 gives a total of 275 instead of 271; the remainder becomes 0 instead of 7, so the expected check digit is 0, not 4. The code is rejected.
Two swapped digits are usually caught too, because the two digits carry different weights: swapping them changes the total by the difference between the digits multiplied by the difference between the weights.
What a check digit cannot do: