How to check that an ISBN is valid
Drop the hyphens, then do the sum that the last digit was made for. For a 13-digit ISBN, multiply the digits by 1, 3, 1, 3 and so on from the left, add the products, and the total must divide by 10. For a 10-digit ISBN, multiply the digits by 10, 9, 8 and so on down to 1 (an X at the end counts as 10), and the total must divide by 11. If the division leaves a remainder, the number was copied or typed wrong somewhere.
That final character is the check digit. The ISBN Users' Manual (seventh edition, a Word file) of the International ISBN Agency defines it as the last character of the string, worked out from all the characters before it, which "may be used to verify the accuracy of the ISBN string". The manual also says that the hyphens or spaces between the parts of an ISBN have no lexical significance: they're there to help you read it, and the sum ignores them.
The 13-digit check, worked through
Since 1 January 2007, agencies have only given out ISBNs of 13 digits. The manual's own appendix uses its ISBN, 978-92-95055-12-4, as the example. Leave the last digit aside and weight the other twelve:
| Digit | 9 | 7 | 8 | 9 | 2 | 9 | 5 | 0 | 5 | 5 | 1 | 2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 9 | 21 | 8 | 27 | 2 | 27 | 5 | 0 | 5 | 15 | 1 | 6 |
The products add up to 126. Divided by 10, that leaves 6, and 10 minus 6 is 4: the check digit the ISBN ends with. When the remainder is 0, the check digit is 0, not 10. To test a whole number in one step, add the check digit to the total: 126 plus 4 is 130, which divides by 10, so the ISBN passes.
The 10-digit check
ISBNs had 10 digits up to the end of 2006, so older books carry the shorter form. Its check uses 11 instead of 10. Wolfram MathWorld gives the rule: weight the first nine digits 10 down to 2, and pick the check digit that brings the total to a multiple of 11. Because a remainder can need a check value of 10, which is two digits, that value is written as the letter X. A total that already divides by 11 gives a check digit of 0, not 11.
MathWorld's own example is 0-8493-9640-9:
| Digit | 0 | 8 | 4 | 9 | 3 | 9 | 6 | 4 | 0 | 9 |
|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
| Product | 0 | 72 | 32 | 63 | 18 | 45 | 24 | 12 | 0 | 9 |
The total is 275, which is 25 times 11, so the number is valid. Change any one digit and the total stops dividing by 11.
One book, two check digits
A 10-digit ISBN and its 13-digit form share nine digits, but each works out its own check digit, so the last characters can differ. MathWorld describes the conversion: put 978 in front of the first nine digits and work out a new check digit, so 0-8493-9640-9 becomes 978-0-8493-9640-3. Going the other way, the 10-digit form of 978-92-95055-12-4 would be 92-95055-12-8: the weighted sum of its first nine digits is 267, and 8 brings it to 275. So a check digit copied across from the other form makes a correct number fail the test. A 13-digit ISBN that begins with 979 has no 10-digit form at all.
What the check misses
The weights of 1 and 3 have a blind spot. Swap two neighbouring digits and the total changes by twice their difference, and when the difference is 5, twice 5 is 10: the remainder stays the same. In 978-92-95055-12-4, swap the 5 and the 0 in the middle and you get 978-92-90555-12-4. Its weighted total is 136, the check digit still comes out as 4, and the wrong number passes. The 10-digit check would have caught it, because a swap there changes the total by the difference of the two digits, which is never 11 or a multiple of it.
A number that passes isn't necessarily a book either. The test proves only that the digits agree with each other. The manual notes that not every combination of registration group and registrant is valid, and it tells publishers not to work out check digits by hand at all: their national ISBN agency can give them lists of ready numbers, or software that makes them. A made-up number with the right final digit passes every check-digit test there is.
Checking a whole library
Doing the sum by hand is fine for one book. Readwyn, the ebook library app this blog belongs to, runs it on every book that has an ISBN. Under “Library health” in the sidebar, the tab “Checks” has one called “Invalid ISBN”: it lists each book whose ISBN has the wrong length, or has 10 or 13 characters and a wrong check digit. It ignores hyphens and spaces, as the manual does. A finding reads, for example, “ISBN 9780141439548 has a wrong check digit”, and its button, “Edit details”, opens the book's details over the list, so you can correct the number from the copyright page and go on to the next finding. An ISBN that fails the check matches no other book when Readwyn looks for duplicates, so fixing it can also turn up a second copy you didn't know you had.
For why an ebook has its own ISBN at all, and who needs one, see Does an ebook need its own ISBN?