13,862,209 members
alternative version

#### Stats

72.1K views
44 bookmarked
Posted 1 Feb 2006
Licenced CPOL

# How to Generate Check Digits and verify your barcodes

, 28 Sep 2006
Generates Check Digits and alows you to verify proper scan of a barcode

## Introduction

This only does 12 digit barcodes for now. if your interested in how this works go to
www.howstuffworks.com/upc.htm whichi is where I got most of my information. I just thought it would be nice to have a quick function to do the math for me and figured I should share ;)

a basic summary goes something like this:

To figure out what the chekdigit is suposed to be add together all of the odd digits and multiply by 3, then add all the even digits and add to the last result. Then find the number that when added to that makes it evenly divisible by to `(10-(total mod 10))`

To make sure a barcode is valid just do the same math but at the end say `(total mod 10)==0`

Its fairly basic but seems a little backwards on a string since they are zero based arrays. You just swap evens for odds

## Share

 Software Developer (Senior) www.ruskin.com United States
PC Programmer/Analyst

## You may also be interested in...

 First Prev Next
 My vote of 5 Global Analyser5-Nov-10 10:16 Global Analyser 5-Nov-10 10:16
 how to generate barcode using UPC-A yutahiga3-Mar-10 14:53 yutahiga 3-Mar-10 14:53
 Re: how to generate barcode using UPC-A Polymorpher3-Mar-10 15:00 Polymorpher 3-Mar-10 15:00
 thanks for this nice work Rola /anglian/12-Jun-07 0:59 Rola /anglian/ 12-Jun-07 0:59
 Re: thanks for this nice work Polymorpher12-Jun-07 7:49 Polymorpher 12-Jun-07 7:49
 NIce Anthony Queen29-Sep-06 4:57 Anthony Queen 29-Sep-06 4:57
 Re: NIce Polymorpher29-Sep-06 7:20 Polymorpher 29-Sep-06 7:20
 Don't limit yourself Charles K. Kincaid21-Mar-06 5:41 Charles K. Kincaid 21-Mar-06 5:41
 Re: Don't limit yourself Polymorpher21-Mar-06 16:04 Polymorpher 21-Mar-06 16:04
 Re: Don't limit yourself Polymorpher3-Oct-06 11:52 Polymorpher 3-Oct-06 11:52
 Last Visit: 17-Feb-19 20:53     Last Update: 17-Feb-19 20:53 Refresh 1