1. Member Join Date
Jun 2010
Posts
1
Rep Power
0

## Checkdigit

How do you calculate a check digit using MODULUS 10.
Last edited by saramathew; 06-12-2010 at 02:48 PM.  Reply With Quote

2. ## using MOD 10 in java
Does that mean there are only 10 different values for the check digit? vs 256  Reply With Quote

3. ## sum of all the digits in the code including the check digit are divisible by 10
Ok. The string consists only of digits.
So add them up and do a modulus 10 and see if the results is 0.  Reply With Quote

4. ## Convert each of the digit characters to its int value. For example "5" gives 5
See the Integer class for a method that does this.

What is the code you posted supposed to do? It seems to print out :s and |s and spaces
Last edited by Norm; 06-12-2010 at 06:02 AM.  Reply With Quote

5. ## Sorry, I got lost. What happened to the check digit?

If the following is true, how did you get the answer: Bar code: :|:: :|||: :||:
1 = :::||
2 = ::|:|
3 = ::||:
4 = :|::|
Last edited by Norm; 06-12-2010 at 06:12 AM.  Reply With Quote

6. ## how to get the check digit for 1234
What is the check code for 1234?
value is chosen so that the sum of all the digits in the code including the check digit are divisible by 10
1+2+3+4 = 10 which is evenly divisible by 10 so the checkdigit would be 0.
For 123 then the checkdigit would be 4  Reply With Quote

7. Member Join Date
Jun 2010
Location
Berlin
Posts
22
Rep Power
0

##  Originally Posted by Norm For 123 then the checkdigit would be 4
1+2+3 = 6, 6 % 10 = 4?! I don't think so ;)  Reply With Quote

8. ##  Originally Posted by HerrK. 1+2+3 = 6, 6 % 10 = 4?! I don't think so ;)
I don't even know where those barcodes came from in this thread; I'm completely lost ...

kind regards,

Jos  Reply With Quote

9. ## 1+2+3 = 6, 6 % 10 = 4?! I don't think so
to find the checkdigit for the string 123 you add the digits up and find the checkdigit that will make the total 10. 1+2+3 = 6 + 4 = 10
4 is the checkdigit  Reply With Quote

10. Member Join Date
Jun 2010
Location
Berlin
Posts
22
Rep Power
0

##  Originally Posted by saramathew How do you calculate a check digit using MODULUS 10.
Well, modulus 10 does not mean to find the digit that will make a total of ten. Let's assume you want to compute the checkdigit of the string 12345:

1+2+3+4+5 = 15, is the checkdigit -5?

Modulus is defined as the remainder of the division, so 1+2+3 (6) MODULUS 10 what be 6 and 15 MODULUS 10 is 5. So you could be sure, that any number you receive is in between 0..9 or in general MODULUS n will return any number in 0 to (n-1).

In Java you could compute the modulus by using the % operator
Java Code:
```int checksum;

checksum = (1+2+3) % 10; // checksum == 6
checksum = (1+2+3+4) % 10; // checksum == 0
checksum = (1+2+3+4+5) % 10; // checksum == 5```  Reply With Quote

11. ## I took a shortcut and didn't do a modulus 10 of 6.  Reply With Quote

12. Member Join Date
Jun 2010
Location
Berlin
Posts
22
Rep Power
0

## You took a shortcut? I don't get what you want to say.

Excuse me, but this is a forum. The posts should help people to get a solution for a problem. The original post asks for a solution to get the modulus by 10 in Java. At some point were getting into some barcodes (and I totaly agree to JosAh, no one has a clue what the barcodes are all about) and now we have shortcuts to the a total of 10?!

I don't know how this should help anyone who wants to know how to get the modulus of 10. And if you have something like a barcode, there is a defined amount of checkdigits. If the last digit of the code is a checkdigit, you have to ensure that this digit is valid (e.g. for decimal numbers in 0 to 9, which could be computed by any value modulus 10). I really can't see what this shortcut is about or even why we are talking about bar codes and stuff. Please add the needed information in future to ensure that this post might help others, too, that have the same (or a close) problem  Reply With Quote

13. ## By shortcut I meant I should have more fully explained my example. I left off the part of doing 6 modulus 10 being equal to 6 as being obvious.

I thought the problem was how to compute the checkdigit for a string of digits. The digit chosen was to result in the sum of all the digits mod 10 being 0. For example: 1+2+3 = 6 + 4 = 10 mod 10 = 0  Reply With Quote

14. ##  Originally Posted by Norm By shortcut I meant I should have more fully explained my example. I left off the part of doing 6 modulus 10 being equal to 6 as being obvious.

I thought the problem was how to compute the checkdigit for a string of digits. The digit chosen was to result in the sum of all the digits mod 10 being 0. For example: 1+2+3 = 6 + 4 = 10 mod 10 = 0
I got that one: we are searching for a single digit d where (sum+d)%10 == 0 but I still have no idea where those barcodes came from ;-)

kind regards,

Jos  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•