The Redstone Comparator has two modes, Subtraction (when the single back torch is On) and Comparison (when the single back torch is Off). You can change the mode by Right Clicking on the Comparator. It has two inputs, one from the front (A) and one from either side (B). It outputs at the back (Where the single torch is). When in Subtraction mode it will output a redstone signal with the strength of A-B (So if A is 12 and B is 2, it will output a strength of 10). In Comparison mode it will output the strength of A if A is greater or equal to B's strength. If a block which has an inventory (like a Chest) is placed beside either of its inputs (A or B) it will use the amount of space used in the inventory as the signal strength. So if a Chest is full it would output a strength of 15, if empty a strength of 0 and other values if its in between.