Code
Ways of writing that hide nothing by design — bases, bits, binary formats, floats, Unicode, Morse, QR codes, Roman numerals, timestamps, coordinates, check digits — read and written both ways.
Check Digits
Checks a number and computes its check digit by Luhn’s rule (patent, 1960), ISBN-13 (the ISBN Users’ Manual), IBAN (ISO 13616, MOD 97-10), Verhoeff’s dihedral code (1969) or five CRCs of Greg Cook’s catalogue. What each catches is found, not claimed: every digit of the number changed, every two neighbours swapped, and the changes let through shown.
History, how it works, how it was checked, limits
History
A check digit lets a number be checked without a list of the valid ones. H. P. Luhn patented his “computer for verifying numbers” in 1960. The ISBN takes its last digit by weights of 1 and 3; the IBAN two check digits by the remainder of a long number by 97, as ISO 13616 sets out after ISO 7064. J. Verhoeff showed in 1969 how the dihedral group of order 10 gives a decimal code that catches every change of one digit and every swap of two neighbours. A cyclic redundancy check divides the bits as a polynomial; Greg Cook’s catalogue lists their parameters.
How it works
A number is read as one with its check digit, and as one without, whose check digit is computed. Luhn doubles every second digit from the right and adds its digits; ISBN-13 weighs its digits 1 and 3; an IBAN moves its first four characters to the end, makes letters numbers and takes the remainder by 97; Verhoeff carries each digit by its place’s power of a permutation and multiplies in the dihedral group; a CRC runs the text’s bytes through its register bit by bit. The reckoning is drawn digit by digit, a CRC’s register byte by byte. Then a valid number is damaged in its first 40 places, each change checked against the whole: each digit made every other digit, each two different neighbours swapped, a byte’s bits flipped one at a time, and every change the check lets through is shown in gold.
How it was checked
The tests give Luhn’s own example, 4872148 with the check digit 4; the ISBN manual’s 978-92-95055-12-4; ISO 13616’s Annex B, BE88 from the BBAN 320-0347134-41, and its four examples of Annex C; Verhoeff’s Cayley table and permutation as printed, with every change of one digit and every swap caught on a thousand numbers; and the catalogue’s check values of the five CRCs. The damage is counted against a check run on each damaged number.
The tests hold 20 checks of this tool; 2 rest on outside material:
- A print’s own example Verhoeff (1969), p. 83: the Cayley table of D5 as printed is a group with 0 its unit, not abelian (1 × 5 is 6, 5 × 1 is 9)
- A print’s own example Verhoeff (1969), p. 96: the permutation (01589427)(36) as a table
Limits
Damm’s quasigroup could not be read in his dissertation, and the ISBN-10 has no rule read from the ISBN agency: both are left out. An IBAN’s length and the shape of each country’s BBAN are not checked, the registry that gives them not having been read; only digits are damaged in an IBAN. What a check catches is shown for the number typed: on another it may differ.
- H. P. Luhn, Computer for verifying numbers, US patent 2,950,048 (filed 1954, granted 1960)
- International ISBN Agency, ISBN Users’ Manual, 7th ed. (2017), Appendix 1: calculating the check digit
- ISO 13616:1997, Banking — International bank account number (IBAN), clause 6 and Annexes B and C (the preview)
- J. Verhoeff, Error detecting decimal codes (dissertation, Amsterdam, 1969), the Cayley table of D5 (p. 83) and the permutation (01589427)(36) (p. 96)
- Greg Cook, Catalogue of parametrised CRC algorithms (2024)