ISBN-13 algorithm does not handle checksum 10

Description

ISBN-13 codes ending with a checksum of `0` always fail, even if valid.

Example of a valid ISBN which will get flagged as invalid:

This is caused by an unhandled edge case in `checkChecksumISBN13` in the following code:

The left-hand side of the equation will produce a sum which is checked against the right-hand side checksum. The sum has a possibility of resulting in the number `10` which will fail when checking against the checksum `0`.

The ISBN-13 algorithm however states that a sum of `10` should be converted to a sum of `0` before being compared to the checksum. https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-13_check_digit_calculation

One possible solution could be an additional modulo operation such as:

Another solution could be an explicit check for `10` which resolves it to `0`.

Environment

None

Activity

Marko BekhtaMarch 28, 2019 at 4:04 PM

Thanks for reporting the issue. I'll take a look into it.

Fixed

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Marko Bekhta
Piet Vandeput

Pull Request

Components

Affects versions

Priority

Created March 28, 2019 at 12:59 PM
Updated June 13, 2019 at 1:45 PM
Resolved April 9, 2019 at 11:47 AM