Question

I'm doing a barcode scanner and doing an in-app conversion of ISBN13 to ISBN10. I could now calculate out the check digit for the ISBN 10 but i do not know how to join it back to a 10 digit number.

What i did was to take out the prefixed "978" for the barcode 9780340961391 which then leaves it with 0340961391 and i only take out the 9 digits, leaving out the check digit of 1 for the isbn 13 which is then left with 034096139.

Then i calculate the check digit of isbn10 which is 2. The problem now is how do i add it to 034096139 to form the final ISBN10 of 0340961392? Thanks :)

Was it helpful?

Solution

I am assuming that your ISBN13 is a string and when adding the check digit back to the SBN number, you would not want to affect the 9 digit number. I would suggest:

/* SBNString = 034096139 */
NSString *ISBN10 = [NSString stringWithFormat:@"%@%u", SBNString, checkDigit];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top