Universal Product Code
From Academic Kids

The UPC (Universal Product Code) was the original barcode widely used in the United States and Canada for items in stores. The first item to be placed under a UPC scanner in a retail store was a 10pack of Wrigley's Juicy Fruit chewing gum at Marsh's supermarket in Troy, Ohio, on June 24, 1974.
UPC_EANUCC12_barcode.png
The UPC (now officially EAN.UCC12) encodes twelve digits as SLLLLLLMRRRRRRE, where S (start) and E (end) are the bit pattern 101, M (middle) is the bit pattern 01010 (called guard bars), and each L (left) and R (right) are digits, seven bits long each. This is a total of 95 bits. The bit pattern for each numeral is designed to be as little like the others as possible, and to have no more than four 1s or 0s in order. Both are for reliability in scanning.
The UPC is only numerals, with no letters or other characters. The first L digit is 0 for ordinary items, 3 for pharmaceuticals, 2 for randomweight items, and 5 for coupons (though stores often ignore this and use 000000 or 999999). The rest of L is the manufacturer code. The first five R digits are the product code assigned by the manufacturer. The last digit R is a check digit, so that errors in scanning or manual entry can be detected. In the UPCA system, the check digit is calculated as follows:
 Add the oddnumbered digits (first, third, fifth, etc.) together and multiply by three.
 Add the evennumbered digits (second, fourth, sixth, etc.) to the result.
 Subtract the result from the nexthigher multiple of ten. The answer is the check digit.
For instance, a UPCA barcode "03600029145X" where X is the check digit, X can be calculated by adding the oddnumbered digits (0+6+0+2+1+5 = 14), multiplying by three (14 × 3 = 42), adding the evennumbered digits (42+3+0+0+9+4 = 58) and subtracting from the nexthigher multiple of ten (60  58 = 2). The check digit is thus 2.
Pharmaceuticals in the U.S. have the remainder of the UPC as their National Drug Control (NDC) number. Randomweight items, such as meats and fresh fruits and vegetables, are assigned a UPC by the store if they are packaged there. In this case, the LLLLL is the item number, and the _RRRR is either the weight or the price, with the first R determining which. Likewise, coupons are supposed to have the coupon code in LLLLL, the amount to be taken off in _RRRR, and whether that amount is a percent or a literal amount encoded in the first R.
Representation
In the barcode, each number is represented by two bar and space configurations. One configuration is used in the "L" digits, while another is used in the "R" digits. This is done so that the barcode can be scanned forwards or backwards, and the scanner can determine from which direction the code is being scanned so that it can be registered correctly. If it were not for this, products could easily be registered incorrectly.
Each digit has four forms, of which two are used in UPCA and three in EAN. For instance, the number 6 can be encoded as:
 0101111 (In the left half of a UPCA barcode)
 1010000 (In the right half of a UPCA barcode)
 0000101 (In an EAN barcode)
 1111010 (unused)
The first and second forms are the one's complement of each other, as are the third and fourth.
The (L) codes for the ten digits are:
 0: 0001101
 1: 0011001
 2: 0010011
 3: 0111101
 4: 0100011
 5: 0110001
 6: 0101111
 7: 0111011
 8: 0110111
 9: 0001011
The (R) codes are simply the one's complement of the (L) codes. All leftside digits have odd parity, while all rightside digits have even parity.
Company prefixes are assigned by EANUCC, which is now using longer company codes (with shorter item codes) for smaller companies.
Expansion
EAN was developed as a superset of UPC, adding an extra digit to the beginning so that there would be plenty of numbers for the entire world. The prefix digit 0 has been reserved for UPC, and in fact the Uniform Code Council has mandated all retail systems be able to recognize UPC and EAN together by the end of 2004. As of 2005, manufacturers will then be able to put only the 13digit codes on their items, rather than having two separate numbers. In addition, this also expands the numbers available for the U.S. and Canada by 50%, adding 10 to 14 to the 00 to 09 (0 to 9 in UPC) already in use.
External links
 Details on the checksum algorithm (http://www.eanint.org/cdcalcul.html)
 Exceptions to the general algorithm for zerosuppressed barcodes (http://www.nepc.sanc.org.sg/html/DataDictionary/EANCode.htm)
 The Internet UPC Database (http://www.upcdatabase.com/)