Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation using Check Digits

Status
Not open for further replies.

scurf

Programmer
Feb 5, 2002
19
GB
Can anyone provide some sample coding which would show an input file with fields which are validated by check digits
Cheers

Garry
 
Garry,
What length are the proposed fields likely to be as this may help you decide what type of check digit process to use?
Marc
 
Sorry Garry,
Having just read that last post I made, I decided it was less than helpful. Let's start again.... There are numerous different types of check digit algorithms around, probably the most popular being Modulus 10 and Modulus 11. These are used in credit card, bar codes and ISBN checks for example. What you need to do is decide which you wish to use.

MOD10 is an algorithm of all the digits bar the last, and the last digit is what is required to make the number divisible by 10. eg a 6 digit number of which the first 5 digits are 32653 would have be multiplied or added to give a number. For simplicity's sake, let's add them:
3+2+6+5+3 = 19, so the check digit for this would be 1 ie. the number needed to take it to 20. The type of math performed on each digit can vary in complexity. Credit card validation works differently on odd and even digits.

MOD11 is a weighted system where each digit is multiplied by a number which is dependent on it relationship in the number. eg in a 7 digit number the first digit is multiplied by 7, the next by 6, then 5 etc. The calculated number is then divided by 11 to give a remainder, and this remainder is subtracted from 11 to give a check digit.

If I've managed to confuse you totally, then sorry, but I didn't want to go on too long. Try


for a much better description of mod11, and

or

for a mod10.

HTH
Marc
 
send me your e-amail and I will send you some code that will do the job for you.
vincecp@hotmail.com

 
It's much more fun doing it yourself. Plus there's the possibility of learning something......
 
Cheers AFPBOY or Vince... I have sent an email to you, cheers for the help. The tests are using modulus 11, the tests are to validate an incoming customer code and part number.
I havent got the spec with me at the moment but I am sure they are both pic 9(5)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top