加载中...

Talk:ISBN

Latest comment: 3 months ago by Largoplazo in topic Question

checking for valid ISBN

edit

Currently the article has a function `CheckISBN()` written in C that returns the error syndrome. However, it expects the input to be `int const digits[10]`, which is quite nonsensical and to the least impractical. Bytes would be more appropriate for digits -- where would you find an ISBN coded as array of ten 32-bit integers? It would be easy to allow to scan a string of bytes that might indifferently be UTF-8 or integer digits. I suggest the following code:

def CheckISBN(digits: Iterable) -> int:
    """Return ISBN error syndrome, zero for a valid ISBN, non-zero for an invalid one.
    Items in 'digits' that can't be cast to integer are ignored."""
    c = t = s = u = 0
    for d in digits:
        try:
            if c&1: u += int(d)    # for 13-digit ISBN
            t += int(d); s += t; c += 1
        except ValueError: pass    # ignore non-digits like spaces, '-', ...
    if c == 10: return s % 11
    if c != 13: raise ValueError(f"Expected 10 or 13 digits, got {c}.")
    return (t+2*u) % 10

If the C implementation is to be retained, one could use `t += digits[i] & 15` to convert ASCII digits to integers. As explained earlier, the argument should be `char digits[10]` to use bytes or characters rather than 32-bit integers. — MFH:Talk 17:31, 20 May 2024 (UTC)Reply

I disagree. That just obfuscates the straightforward algorithm. KISS principle ToraNeko (talk) ToraNeko (talk) 10:32, 31 May 2024 (UTC)Reply

Semi-protected edit request on 9 September 2024

edit

Mr Shakti raj}it suggests in this application software 2409:40E5:BB:AAD5:D842:FEFF:FE58:E11D (talk) 18:46, 9 September 2024 (UTC)Reply

  Not done: it's not clear what changes you want to be made. Please mention the specific changes in a "change X to Y" format and provide a reliable source if appropriate. ⸺(Random)staplers 20:29, 9 September 2024 (UTC)Reply


Question

edit

Is it reasonable to say "Some publishers, such as Ballantine Books, would sometimes use 12-digit SBNs where the last three digits indicated the price of the book;" or should we say "would append the book price to the SBN, creating a 12 digit number". All the best: Rich Farmbrough 20:25, 3 October 2025 (UTC).Reply

I don't know, but either way I would change "would V" to "Ved". Largoplazo (talk) 20:59, 3 October 2025 (UTC)Reply
What is V? --Redrose64 🌹 (talk) 10:05, 4 October 2025 (UTC)Reply
It's a placeholder for whatever verb is there. Largoplazo (talk) 11:35, 4 October 2025 (UTC)Reply