Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checksum calculation for ISBN-10 is wrong #1

Closed
thinkmobilede opened this issue Aug 9, 2015 · 3 comments
Closed

Checksum calculation for ISBN-10 is wrong #1

thinkmobilede opened this issue Aug 9, 2015 · 3 comments
Assignees
Labels

Comments

@thinkmobilede
Copy link

Thanks for the great work.

I found that the checksum calculation for ISBN-10 seems to be wrong. Line 285 should be
$sum = (($c[0] * 1) + ($c[1] * 2) + ($c[2] * 3) + ($c[3] * 4) + ($c[4] * 5) + ($c[5] * 6) + ($c[6] * 7) + ($c[7] * 8) + ($c[8] * 9)) % 11;

Best regards,
Christian

@clemlatz clemlatz added the bug label Aug 10, 2015
@clemlatz clemlatz self-assigned this Aug 10, 2015
@clemlatz
Copy link
Member

Well not according to what I understand of : https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation

Do you have an ISBN example for which the checksum calculation fails ?

@thinkmobilede
Copy link
Author

The ISBN 3464603520 gives 11 as checksum. I checked your link. It is iinteresting that de.wikipedia.org and en.wikipedia.org have different calculations. Based on the English version you are missing one modulo and the calculation has to be

$sum = (11 - (($c[0] * 10) + ($c[1] * 9) + ($c[2] * 8) + ($c[3] * 7) + ($c[4] * 6) + ($c[5] * 5) + ($c[6] * 4) + ($c[7] * 3) + ($c[8] * 2)) % 11) % 11;

@clemlatz
Copy link
Member

Thanks for the additional info! I fixed it and added some tests so it won't happen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants