The number of UPC-A and UPC-E barcodes are limited by the standards used to create them. ; UPC-A: \begin{align} \text{(possible values per left digit)} ^ \text{(left digits)} &\times \text{(possible values per right digit)} ^ \text{(5 right digits)}\\ = 10^6 &\times 10^5 = 100,000,000,000. \end{align} ; UPC-E: \begin{align} \text{(possible values per digit)} ^ \text{(digits)} &\times \text{(possible parity patterns per UPC-E number)}\\ = 10^6 &\times 2 = 2,000,000.\end{align}
Number system digit Below is a description of all possible number systems with the corresponding 12-digit UPC-A numbering scheme LLLLLLRRRRRR, where L denotes the numbering system digit and R the check digit. ; 0–1, 6–9 : For most products. The LLLLL digits are the manufacturer code (assigned by local
GS1 organization), and the RRRRR digits are the product code. ; 2 : Reserved for local use (store/warehouse), for items sold by variable weight. Variable-weight items, such as meats, fresh fruits, or vegetables, are assigned an item number by the store, if they are packaged there. In this case, the LLLLL is the item number, and the RRRRR is either the weight or the price, with the first R determining which (0 for weight). ; 3 : Drugs by
National Drug Code (NDC) number. Pharmaceuticals in the U.S. use the middle 10 digits of the UPC as their NDC number. Though usually only
over-the-counter drugs are scanned at point of sale, NDC-based UPCs are used on prescription drug packages and surgical products and, in this case, are commonly called UPN Codes. ; 4 : Reserved for local use (store/warehouse), often for
loyalty cards or store coupons. ; 5 :
Coupons. The LLLLL digits are digits 2-6 of the product's UPC prefix, the next three RRR are a family code (set by manufacturer or supplied by the coupon clearing house), and the next two RR are a value code (according to the GS1 value code table), which determines the amount of the discount. These coupons can be doubled or tripled.
Check digit calculation The UPC includes a check digit to detect common data entry errors. For example, UPC-A codes choose the check digit x_{12} to satisfy the
check digit equation: :(3x_1 + x_2 + 3x_3 + x_4 + 3x_5 + x_6 + 3x_7 + x_8 + 3x_9 + x_{10} + 3x_{11} + x_{12}) \equiv 0 \pmod{10}. If an entered code does not satisfy the equation, then it is not a valid UPC-A. The UPC-A check digit may be calculated as follows: • Sum the digits at
odd-numbered positions (first, third, fifth,..., eleventh). • Multiply the result by 3. • Add the digit sum at
even-numbered positions (second, fourth, sixth,..., tenth) to the result. • Find the result
modulo 10 (i.e. the remainder, when divided by 10) and call it . • If is zero, then the check digit is 0; otherwise the check digit is . For example, in a UPC-A barcode "03600029145
x12", where is the unknown check digit, may be calculated by: • Sum the odd-numbered digits (0 + 6 + 0 + 2 + 1 + 5 = 14). • Multiply the result by 3 (14 × 3 = 42). • Add the even-numbered digits (42 + (3 + 0 + 0 + 9 + 4) = 58). • Find the result modulo 10 (58 mod 10 = 8 =
M). • If is not 0, subtract from 10 (). Thus, the check digit is 2. The check digit equation is selected to have reasonable error detection properties (see
Luhn algorithm). • UPC-A can detect 100% of single digit errors. • : A single digit error means exactly one digit is wrong. Let the difference modulo 10 of the erroneous digit and the correct digit be . The value of cannot be zero because that means the digits are the same, but can be any other value in {1, 2, 3, 4, 5, 6, 7, 8, 9}. If the error digit is in an odd position (weight 1), the left hand side of check digit equation changes by and the equivalence is no longer zero. If the error digit is in an even position (weight 3), then the left hand side changes by , but that change is also nonzero modulo 10, so the check digit equation is not satisfied. • UPC-A can detect about 89% of transposition errors. Specifically, if and only if the difference between two adjacent digits is 5, the UPC-A can't detect their transposition. • If 2 neighboring digits are transposed, then one of the digits will be weighted by 1, and the other digit will be weighted by 3, where is the difference between the two digits. If the digits were in their correct order, they would contribute • :: 1a + 3b = 1a + 3(a+d) = 4a + 3d • : to the left hand side of the check digit equation. In the transposed order, they contribute • :: 1b + 3a = 3a + 1(a+d) = 4a + d. • : to the LHS. Subtracting the two contributions gives how much they change the LHS: • :: (4a + 3d) - (4a + d) = 2d • : An error will be detected as long as the modular change is nonzero; if modulo 10, then the change will not be detected. Consequently, only when the character difference will an error be undetected (when the degenerate "transposition" is not an error). • Next consider how often a transposition has a distance of 5. ::::Here is the
Table of d-transpositions for UPC-A barcodes, where d \in \{0, 1, 2, \ldots, 9\}: :::: ::::Row
Sum contains the number of
d-transpositions, therefore the proportion of non-detectable transposition errors is (ignoring the transpositions where ): :::::\frac{10}{18 + 16 + 14 + 12 + 10 + 8 + 6 + 4 + 2}=\frac{10}{90}=11.111\ldots\%. :::::::::::::::::::::::::::▯ == Variations ==