Results 1 to 14 of 14
Thread: Checkdigit
- 06-12-2010, 04:15 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
- 06-12-2010, 04:28 AM #2
Does that mean there are only 10 different values for the check digit? vs 256using MOD 10 in java
- 06-12-2010, 04:51 AM #3
Ok. The string consists only of digits.sum of all the digits in the code including the check digit are divisible by 10
So add them up and do a modulus 10 and see if the results is 0.
- 06-12-2010, 05:58 AM #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.
Then add them up.
What is the code you posted supposed to do? It seems to print out :s and |s and spacesLast edited by Norm; 06-12-2010 at 06:02 AM.
- 06-12-2010, 06:07 AM #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.
- 06-12-2010, 02:23 PM #6
What is the check code for 1234?how to get the check digit for 1234
1+2+3+4 = 10 which is evenly divisible by 10 so the checkdigit would be 0.value is chosen so that the sum of all the digits in the code including the check digit are divisible by 10
For 123 then the checkdigit would be 4
- 06-12-2010, 02:33 PM #7
Member
- Join Date
- Jun 2010
- Location
- Berlin
- Posts
- 22
- Rep Power
- 0
- 06-12-2010, 03:15 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
- 06-12-2010, 03:54 PM #9
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 = 101+2+3 = 6, 6 % 10 = 4?! I don't think so
4 is the checkdigit
- 06-12-2010, 04:06 PM #10
Member
- Join Date
- Jun 2010
- Location
- Berlin
- Posts
- 22
- Rep Power
- 0
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
- 06-12-2010, 04:12 PM #11
I took a shortcut and didn't do a modulus 10 of 6.
- 06-12-2010, 04:21 PM #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
- 06-12-2010, 04:28 PM #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
- 06-12-2010, 04:48 PM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks