> > -----Original Message-----
> > From: Tomasz Korycki [mailto:[EMAIL PROTECTED]
> > Sent: 11 August 2003 05:26
> > To: [EMAIL PROTECTED]
> > Subject: OT: Re: MySQL field data type for ISBN numbers
> > 
> > 
> > At 21:08 2003-08-10, you wrote:
> > >On Sun, Aug 10, 2003 at 05:25:05PM -0700, James Johnson wrote:
> > > >
> > > > I have a MySQL database for books. The ISBN field is set 
> > as varchar(15) and
> > > > I've put a test ISBN number in of 1-1111-111-11.
> > >
> > >Note that ISBN numbers are a maximum of 13 characters, not 15.  Ten
> > >digits, three dashes.  If you really want to save space, the 
> > last digit
> > >is just a check digit and can always be determined through a 
> > formula on
> > >the other digits, so as long as you verify every ISBN before 
> > you INSERT
> > >it, you can save another digit.
> > 
> > Hmmm...And how do You come up with an 'X' as the last digit, 
> > as many books 
> > on the shelves around me do?
> > 
> I don't know which particular check digit algorithm is used for ISBNs
> but the mod-11 algorithm uses the digits 0-9 and X for 10.
> 

If anyone is interested in calculating the check digit ...

The ISBN layout is:
1: country code
2 - 3: publisher
4 - 9: book number assigned by publisher
10: check digit (if this equals 10, X is used)

The algorithm uses weighted modulo 11 for calculating the check digit on
an ISBN as follows: (a is the ISBN minus the check digit)

Calculate the sum obtained by adding (10 * a[1]) + (9 * a[2]) + (8 *
a[3]) + (7 * a[4]) + (6 * a[5]) + (5 * a[6]) + (4 * a[7]) + (3 * a[8]) +
(2 * a[9])

Reduce the sum modulu 11 to obtain integer b (>=1 b <=11)

The check digit is 11 - b

This is an error-detecting algorithm - it won't tell you where the error
is, only that there is one.

-- 
/* All outgoing email scanned by AVG Antivirus /*
Amer Neely, Softouch Information Services
W: www.softouch.on.ca
E: [EMAIL PROTECTED]
V: 519.438.5887
Perl | PHP | MySQL | CGI programming for all data entry forms.
"We make web sites work!"

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to