Numbers on the right side of the middle guard bars are optically the inverse of the numbers to the left. In other words, while a number on the left side of the UPC will be made up of black bars and white spaces, the same number on the right side would be indicated by the inverse (what was black on the left is now white and what was white is now black).
In the illustration above, the "4" digit (shown in detail) is 1011100 (bar × 1, space × 1, bar × 3, space × 2). If the "4" digit were on the left hand side it would be 0100011 (space × 1, bar × 1, space × 3, bar × 2).
This inversion enables the bar code to be scanned from left-to-right or right-to-left. Left-side digits consist of an even number of white space bits and an odd number of black bars. Right side digits are the opposite. Using this difference, the scanning software knows if it read the code the correct way or upside down.