Cut the knot: learn to enjoy mathematics
A math books store at a unique math study site. Learn to enjoy mathematics.
Google
Web CTK
Best sites for teachers
Sites for teachers
Sites for parents
Terms of use
Awards

Interactive Activities
CTK Exchange
CTK Insights - a blog

Games & Puzzles
What Is What
Arithmetic/Algebra
Geometry
Probability
Outline Mathematics
Make an Identity
Book Reviews
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
Visual Illusions
My Logo
Math Poll
Cut The Knot!
MSET99 Talk
Other Math sites
Front Page
Movie shortcuts
Personal info
Reciprocal links
Privacy Policy

Guest book
News sites

Recommend this site

Best sites for teachers
Sites for teachers
Sites for parents

Education & Parenting

Manifesto: what CTK is about Search CTK Buying a book is a commitment to learning Table of content Things you can find on CTK Chronology of updates Email to Cut The Knot Recommend this page

Barcode Encoding

Barcodes have been born in 1973 along with the UPC encoding. Barcodes are graphical, machine readable representations of the UPC, its variants and extensions.

In a barcode, each digit of an encoding is represented by seven black or white bars of equal size. Visually, two or more adjacent black bars appear as a single wide bar; white bars appear as space separators (also of varying size) between the black bars. If we call such wide (black or white) bars generalized bars, then, as a rule, a digit's representation always consists of four such generalized bars, which by necessity, interlace: either white-black-white-black or black-white-black-white.

Possible variants of 7-bar representation are shown in the diagram below.

 

An UPC-A code consists of twelve digits that are split into six left and six right digits. The digits in the two groups are barcoded differently. To barcode the first six (left) digits we use the "Left side (odd parity)" representation. For the next six (right) digits, use the "Right side" representation. One can easily observe that the difference between the two is in exchange of colors: white bars in one are black in the other, and vice versa. All twelve digits are represented by seven bars each, although on a barcode label the first and the last digits are place outside the barcode whilst the "middle" 10 digits are drawn beneath the barcode.

In the EAN-13 encoding the situation is somewhat different. In an EAN-13 code, the first digit does not have a barcode representation of its own, but its value has an effect on the representation of the next six digits. The entries in the following table refer to the "Left side (odd parity)" and the "Left side (even parity)" tables above.

(Note that the "Left side (even parity)" barcodes are the mirror images of the corresponding "Right side" barcodes.)

 
First number
system digit
Left side 6 digits
1 2 3 4 5 6
0 (UPC-A)  odd   odd   odd   odd   odd   odd 
1 odd odd even odd even even
2 odd odd even even odd even
3 odd odd even even even odd
4 odd even odd odd even even
5 odd even even odd odd even
6 odd even even even odd odd
7 odd even odd even odd even
8 odd even odd even even odd
9 odd even even odd even odd

As you can observe, UPC-A is easily (and commonly) embedded into EAN-13 by prepending a 0 as the first digit.

Besides the aforementioned fact that every digit's barcode consists of four bars, we may make additional observations:

  1. First of all, left side barcodes of either parity are of the form white-black-white-black and thus end in a black bar. The right side barcodes are of the form black-white-black-white and end in a space.

  2. No (generalized) bar nor space is wider than four (regular) bars.

Any barcode starts and ends with three "guard bars": black-white-black. Barcodes corresponding to "two-halves" encodings, like the UPC-A and EAN-13, also feature a middle guard in the form white-black-white-black-white.



Copyright © 1996-2008 Alexander Bogomolny

28735619Page copy protected against web site content infringement by Copyscape


Search:
Keywords:


Latest on CTK Exchange
Math
Posted by Laura
2 messages
06:56 AM, Apr-15-08

Divisibility rules - Jargon buste ...
Posted by Carolyn
2 messages
08:35 AM, Apr-04-08

drawing puzzle
Posted by martin gran
31 messages
06:53 PM, May-09-08

conway's game of life
Posted by frequency
0 messages
11:52 PM, May-12-08

Mistake on the page (an aside, Be ...
Posted by Max
4 messages
10:28 AM, Feb-28-08

Deriving functions based on diffe ...
Posted by ke_45
1 messages
12:47 PM, May-10-08

Josephus Flavius (correction)
Posted by David Turner
0 messages
08:17 AM, May-14-08