ISBN check digit calculation.
ISBN (International Standard Book Number) is a unique numeric book identifier, required for the distribution of a book in retail chains and automation of work with the publication.
ISBN based upon 9-digit SBN (Standard Book Number) created in 1965. There are two types of ISBN. First, called ISBN-10 (10 means «10-digit») is also deprecated format. It was developed and published in 1970 by ISO. ISBN-10 consists of four parts:
The most interesting part for us is the last one called «check digit». A check digit is a form of redundancy check used for error detection on identification numbers. It should be noted here that the last digit can be the letter «X», which represents the value 10.
Currently active (since 2007) standard, ISBN-13 looks very similar to ISBN-10. The difference is that ISBN-13 also includes EAN prefix (it's always 978 or 979) and check digit can not be a letter «X». Here is the structure of the ISBN-13 number:
To learn more about ISBN you can visit International ISBN Agency website. There is a comparison table of ISBN formats:
Standard | Length | EAN prefix | X as check digit |
---|---|---|---|
SBN | 9 | No | Yes |
ISBN-10 | 10 | No | Yes |
ISBN-13 | 13 | Yes | No |
It is possible to convert SBN to ISBN-10: just add prefix 0 to SBN:
SBN: 12345678-9
ISBN-10: 012345678-9
Also you can convert ISBN-10 to ISBN-13 by adding prefix 978 and recalculating check digit:
ISBN-10: 012345678-9
ISBN-13: 978-012345678-6
SBN check digit.
To calculate SBN check digit you can convert SBN to ISBN-10 and calculate ISBN-10 check digit (it will be the same as SBN check digit).
ISBN-10 check digit.
ISBN-10 check digit must range from 0 to 10 (X). To calculate ISBN-10 check digit you can use following formula:
For example, lets calculate check digit of ISBN-10 123-456-789-_:
so check digit is X and ISBN-10 is 123-456-789-X.
ISBN-13 check digit.
Let
then ISBN-13 check digit equals
JavaScript implementation: