We're updating the issue view to help you get more done. 

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:

1 978-3-598-21536-0

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

1 return 10 - sum % 10 == ( checkSum - '0' );

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:

1 return (10 - sum % 10) % 10 == ( checkSum - '0' );

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

Environment

None

Status

Assignee

Marko Bekhta

Reporter

Piet Vandeput

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

6.0.13.Final

Priority

Major