문제

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 :)

도움이 되었습니까?

해결책

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top