>> What do people think of this?<<
Nice work. You can do this in pure SQL via table look-up, but it is
awful. I tried it when i wrote THINKING IN SETS. Uggh!
>> Do the function names make sense, seem reasonable to use? <<
Minor nit -- the current convention is "<verb>_<object>" name for code
modules, "computer_verhoeff()" or something might be better.
>> Also, in passing, I have heard that there is more than one verhoeff 'style' out there, and that they return different numbers. But I can't find a reference to these on wikipedia. Does anyone have any idea about the truth of this multiple style stuff? <<
I would guess "false" because you would need a group that had <= 10
elements to map to the digits and I think D-5 is the only one in that
range with the right properties. However, if the number of elements
is increased, I don't know.
Martin Bowes - 25 Sep 2008 11:07 GMT
Hi Jim,
Thanks for the input. Doing that in SQL would have been an interesting
exercise!
FYI. I've changed the thing to be:
** (char ) generate_digit((varchar )scheme, (varchar )string);
** This generates the check digit on the string using the
nominated
** scheme(verhoeff, Luhn and Luhn Mod N, etc)
**
** (int1 ) validate_digit((varchar )scheme, (varchar )string);
** Validates the string, returning 1 for yes and 0 for no.
In regards to the 'styles' of verhoeff, I've tracked down the source of
this to an algorithm in 'Numerical Recipes'. The essential difference
between that algorithm and the ones described in Wikipedia etc is:
(Numerical Recipes) k=ij[k][ ip[(c+2) % 10][7 &m++] ];
(mine) k = d[k][ F[7 & m++][atoi(&c)] ];
For some reason NR is adding 2 to each digit (c), and then modulo 10 to
get it to fit into their ip[10][8].
I'm in the process of setting up a trial of the NR algorithm against
mine to see if it actually produces different digits. I imagine it must.
In which case, I'll modify my code to accept an input of "verhoeff[N]"
where N is an offset, and code accordingly.
Marty
-----Original Message-----
From: info-ingres-bounces@kettleriverconsulting.com
[mailto:info-ingres-bounces@kettleriverconsulting.com] On Behalf Of
--CELKO--
Sent: 24 September 2008 17:17
To: info-ingres@kettleriverconsulting.com
Subject: Re: [Info-Ingres] verhoeff function for Ingres
>> What do people think of this?<<
Nice work. You can do this in pure SQL via table look-up, but it is
awful. I tried it when i wrote THINKING IN SETS. Uggh!
>> Do the function names make sense, seem reasonable to use? <<
Minor nit -- the current convention is "<verb>_<object>" name for code
modules, "computer_verhoeff()" or something might be better.
>> Also, in passing, I have heard that there is more than one verhoeff 'style' out there, and that they return different numbers. But I can't
find a reference to these on wikipedia. Does anyone have any idea about
the truth of this multiple style stuff? <<
I would guess "false" because you would need a group that had <= 10
elements to map to the digits and I think D-5 is the only one in that
range with the right properties. However, if the number of elements
is increased, I don't know.
_______________________________________________
Info-Ingres mailing list
Info-Ingres@kettleriverconsulting.com
http://www.kettleriverconsulting.com/mailman/listinfo/info-ingres