home *** CD-ROM | disk | FTP | other *** search
- Xref: wupost comp.misc:8338 misc.misc:8172 rec.misc:883 alt.sources:3971
- Path: wupost!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!gvlf3.gvl.unisys.com!widener!news
- From: sven@cs.widener.edu (Sven Heinicke)
- Newsgroups: comp.misc,misc.misc,rec.misc,alt.sources
- Subject: Re: ISBN check sum digit
- Message-ID: <kca87gINN8iv@ashley.cs.widener.edu>
- Date: 4 Sep 91 18:07:44 GMT
- References: <1991Sep3.182314.4794@edsr.eds.com>
- Followup-To: comp.misc
- Organization: Widener CS Dept
- Lines: 65
- NNTP-Posting-Host: ashley.cs.widener.edu
-
- n
- In <1991Sep3.182314.4794@edsr.eds.com>, jamii@edsr.eds.com writes:
- > 0-xxx-yyyy-z where xxx seems to be publisher code, yyyy is the book code,
- > the 0 is the language (or country) code. Does anyone know if this speculation
- > is correct, and if so what the check digit algorithm is? It doesn't seem to
- > be a simple summation, since I have 3 books that differ only in the last y
- > digit, and only by one, and the check digit differs by 2 in each case.
- Xref: widener comp.misc:2342 misc.misc:1846 rec.misc:199 alt.sources:1166
-
- Here is a program I hacked together a few months ago that will tell
- you if an ISBN code is good or not. It is just a 10D dot product with
- the numbers that are coprime to 11 (1 to 10). Because 10 is coprime
- to 11 too, and 10 is not a single digit the ISBN code uses a X instead
- of 10, X is only used when it is the check digit (so far what I have
- found). I only know about the check digit, I don't know about the xxx
- and yyyy digits.
-
- There is a proof (I got it from "Abstract Algebra" by J. Gallen (I
- don't know the ISBN number)) but I will not resite it right here,
- right now.
-
- About my program, I worte in using GNU C on a Sun sparc 1, have not
- tried it anywhere else and I have not trouble shooted very much.
-
- /* International Standard Book Number (ISBN) tester.
- By Sven Heinicke */
- #include <stdio.h>
-
- int isbn();
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- char *code,reply;
-
- if(argc == 1)
- {
- code = (char*)malloc(sizeof(char) * 14);
- printf("Enter a ISBN code: ");
- fflush(stdout);
- scanf("%s",code);
- }
- else
- code = *(argv + 1);
- printf("The ISBN code %s is ",code);
- reply = isbn(code);
- if(reply == 0)
- puts("good.");
- else
- printf("bad.\nThe checksum returned %d.\n",reply);
- }
-
- int isbn(code)
- char *code;
- {
- int loop,n = 0;
-
- for(loop = 10;loop > 0;loop--)
- {
- if(*code == '-')
- code++;
- if((loop == 1) && ((*code == 'x') || (*code == 'X')))
- n += 10;
- else
- n += (*code - '0') * loop;
- code++;
- }
- return(n % 11);
- }
- --
- sven@cs.widener.edu Widener CS system manager
- Sven Mike Heinicke and Student
- (pssmheinicke@cyber.widener.edu (if you must))
-