I would like editor access to the wiki, my username is jebarnard and I would like to modify:
The math is incorrect for the luhn_generate_checkdigit function, it returns invalid values for 1, 10, 100, 1000 ....
FROM generate_series(0, ceil(log($1))::integer - 1) AS n
should be changed to:
FROM generate_series(0, floor(log($1))::integer) AS n
Thanks,
Joel Barnard
Luhn algorithm implementation by Craig Ringer in pure SQL (PostgreSQL function dialect, but should be easily adapted to other DBMSs). Note that this implementation is ... wiki.postgresql.org |