How Barcodes Work

When a laser scans a barcode it scans through 95 evenly spaced columns and check to see if each one of those columns reflects the laser light or not. A computer only understands 1 and 0, any of the columns reflecting virtually no light will be considers as a 1, and any columns reflecting a lot of light considers a 0.

Scanners are reading columns / bars from left to right, the first column reflects virtually no light so it interpret it as a 1, the second column / bar reflects a lot of light so it interpret it as a 0, etc.

A scanner continues reading all the barcodes and comes up with a number that is 95 digits long, full of 1s and 0s, these 1s and 0s is then grouped in to 15 different sections, 12 of these sections is used for the numbers that you see at the bottom of the barcodes, the other three is used as guards. These guards let the scanner know where the barcode begins and ends, that is important because the numbers on the left is identified based on one set of codes, and the numbers on the right side is identified by another set of codes, these codes are different because the scanner must know whether treating the barcode from left to right or whether the barcode is reading upside down. It figures that out best on how many 1s there is in the codes for each digit.

The codes on the left always have an odd number of 1s and the codes on the right always have an even number of 1s, so if the computer reads an even number of codes on the left hand side it knows that the barcode is flipped upside down, so when it reads it can just flip the numbers around before processing them. As an additional check, all the codes on the left side begin with a 0 and end with a 1, while all the codes on the right side begin with a 1 and end with a 0.