MATHEMATICAL EXCURSIONS Math and Bar Codes If you examine most consumer products, you will find a small rectangular area with a pattern of black bars and white spaces of various widths on the packaging or the product itself. These patterns give the Universal Product Code (UPC) for the product. These codes speed up the checkout process at retail stores and help the store keep track of inventory. UPCs are assigned by the GS1 US company (formally known as the Uniform Code Council). Manufacturers pay an annual fee for the right to have a six-digit manufacturer identification number and are given guidelines on how to use the other six digits of a UPC. Below is the UPC code from a case of bottled water. The black bars and white spaces make up the machine-readable code and the human-readable 12-digit UPC number is given below the bars and spaces. The first six digits give the manufacturers identification number with the first digit identifying product type. The next five digits give the item number. The last digit of the UPC is a check digit. The UPC number does not include the price of the item. A bar code reader scans the UPC with an optoelectric device, transforms the optical image into ASCII binary code (See Section 1.2.), and sends the binary code to the store s point of sale computer. The computer looks up the price and sends the information back to the cash register. All of this taking about 0.3 seconds. How do the Black Bars and White Spaces Produce the UPC Number? The width of a black bar or white space gives it a value. The bars and spaces that follow show how to get a value of 1 2, 3, or 4 denoted as,,, for bars and,,, for spaces. page 49
The digits from 0 to 9 are encoded according to the following chart where a certain width can represented by a bar or a space. Digit Width Code UPC Code 1 UPC Code 2 0 3-2-1-1 1 2-2-2-1 2 2-1-2-2 3 1-4-1-1 4 1-1-3-2 5 1-2-3-1 6 1-1-1-4 7 1-3-1-2 8 1-2-1-3 9 3-1-1-2 Each UPC starts and ends with the code and has the code in the middle. The digits proceed from left to right using the codes in the above chart. Start Middle End Manufacturer s Identification Product Number and Digit Check page 50
Example 1 Decode the last three digits of this UPC. Solution: First we look at the last three labeled parts of the bar code, and compare them with the values given in the above chart. Example 2 = 1-1 - 3-2 = 4 = 1-2 - 1-3 = 8 = 1-4 - 1-1 = 3 A UPC starts with the number 57, what is the bar code for this? Solution: From the table, we find that the bar code for 57 is Therefore, we have the barcode shown below. 5 7 How is the Check Digit Used? If the first eleven digits of the UPC are dddddddddd d 1 2 3 4 5 6 7 8 9 10 11 and the check digit is c k, a valid UPC satisfies the following calculation. ( 3d + d + 3d + d + 3d + d + 3d + d + 3d + d + 3d = a multiple of 10. 1 2 3 4 5 6 7 8 9 10 11 In the above bottled water UPC, the first eleven digits are 0, 4, 9, 0, 0, 0, 0, 3, 1, 6, 5 and the check digit is 2. = ( 30 + 4+ 3 9+ 0+ 30 + 0+ 3 0+ 3+ 31 + 6+ 3 5)+ 2 = (4 + 27 + 3 + 3 + 6 + 15) + 2 = 60 This shows that it is a valid UPC. page 51
Example 3 Is this number, 0 94187 01089 1, from a Bayer Aspirin Convenience Pack a valid UPC number? Solution: To be a valid UPC number the check digit procedure described above must produce a multiple of 10. The first eleven digits are 0, 9, 4, 1, 8, 7, 0, 1, 0, 8, 9 and the check digit is 1. = ( 30 + 9+ 3 4+ 1+ 3 8+ 7+ 3 0+ 1+ 30 + 8+ 3 9)+ 1 = (9 + 12 + 1 + 24 + 7 + 1 + 8 + 27) + 1 = 89 + 1 = 90 Since 90 is a multiple of ten, the Bayer Aspirin Convenience Pack had a valid UPC number. Every scanned UPC goes through this calculation. If the result of the calculation is not a multiple of 10, the item must be rescanned or the UPC number must be manually entered. A common error in reading a UPC is having one digit read incorrectly. Let s examine how the check system works if this happens. Example 4 Suppose the Bayer Aspirin Convenience Pack s UPC number, 0 94187 01089 1, has its fourth digit read as a 2 instead of a 1. Show that this error would be caught with the check calculation. Solution: Let s perform the check computation with the incorrect fourth digit. = ( 30 + 9+ 3 4+ 2+ 3 8+ 7+ 3 0+ 1+ 30 + 8+ 3 9)+ 1 = (9 + 12 + 2 + 24 + 7 + 1 + 8 + 27) + 1 = 91 The result was not a multiple of ten, so something is wrong. This check system catches 100% of single digit errors and most of the other errors that can occur when scanning or manually entering a UPC. This excursion has made you aware of how a bar code system works. It should now be easier to understand how bar codes work in other areas such as store coupons, retail club card account numbers, U.S. Postal Service zip codes, United Parcel Service (UPS) package identification numbers, etc. page 52
Exercises 1. What does UPC stand for? 2. What is the check procedure for a UPC? 3. How are black bars and white spaces used to represent numbers? 4. What sequence happens for a cash register to ring up the price of an item from its UPC? In Exercises 5-7, find the UPC number from the following bar codes. 5. 6. 7. In Exercises 8-12, the UPC numbers of various products were written down. Determine if they were copied correctly using the UPC check system. 8. Vicks Cherry Cough Drops: 3 23900 00127 5 9. Coby Personal CD Player: 7 16829 13104 6 10. Beer Nuts: 0 70824 00166 4 11. Master Lock: 0 71649 36650 2 12. Apple ipod case: 8 07360 04150 3 13. Use the UPC in Problem 8 to show what happens to the check procedure if you reverse two adjacent digits. 14. Check the UPCs on two of your favorite products to see if the check system works. 15. If the first 11 digits of a UPC are 4 12309 06527, what is its check digit? page 53