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: `
{code:java} 978-3-598-21536-0 ` {code}
This is caused by an unhandled edge case in `checkChecksumISBN13` in the following code: ` {code:java} return 10 - sum % 10 == ( checkSum - '0' ); ` {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.
One possible solution could be an additional modulo operation such as ` :
{code:java} return (10 - sum % 10) % 10 == ( checkSum - '0' ); ` ). {code}
Another solution could be an explicit check for `10` which resolves it to `0`. |
|