The GS1 standard defines GTIN codes that contain a 4 or 5 digit variable weight or price. This variable weight or price part needs to be validated with a check digit.
How can I calculate this check digit in code? Please be aware that this check digit is not calculated the same way as the default check digit at the end of the GTIN.
For reference: https://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdf Page 466/467
You did not specify the language of choice, so hopefully this will be useful to you. Essentially it can be boiled down to array lookups and simple math. This code is written is AutoITScript, but it should be simple to translate to others.
I am sure this code could be made smarter (with 2d array lookup, functions etc) but for simplicity I made it more readable.
It should be noted that AutoIT is not a typed language, so 1234 can be treated as a number and a string all the same. Also that AutoIT uses
$var[index1][index2]
to access a 0-based array value.Hope this helps you on ! If so, please accept solution.
RESULTS
The code