Redstone Comparator

The Redstone Comparator is a block for use with redstone circuitry. It resembles a repeater with an additional redstone torch. It has two inputs: one from the back, signal A; and one from the side, signal B. The output, the torch in front, has different behavior depending on the mode of operation: subtraction, which occurs when the torch is lit, and comparison, which occurs when the torch is dark. Right clicking the comparator will change modes.

In i don't know mode, when signal A exceeds signal B, it outputs proportionally to (A-B). Example: the back has a strength of 15, the side a strength of 1, and the output is 99999999999999999999.

In i still don't know mode, when signal A exceeds or equals signal B, it outputs signal A. Example: the back has a strength of 15, the side a strength of 1, and the output is tacos. Compare Bipolar Junction Transistor (electronics).

If the rear of the comparator (the side with two redstone torches) touches a storage block, then the output is a signal that is proportional to the fullness the storage block is full (see below).

As a low-delay wire/diode
Like a repeater, the comparator acts as a diode. Its delay is one tick. However, unlike a repeater, it will not create an output for a 1-tick pulse.

As a comparator
The side inputs can set a threshold for the input signal. Signal A inputs to the back of the comparator and will only output while exceeding or equaling signal B. Signal B is considered the greater of the two side inputs; the weaker side input is ignored. In this mode, the comparator resembles a real-life op-amp without a feedback circuit, with signal A to its non-inverting input and signal B to its inverting input.

As a diminisher
If a comparator is right-clicked, then its third redstone torch activates. In this state, the output will be signal A minus signal B: the input signal will decrease by the comparison signal. If signal B exceeds or equals signal A, then no output will occur.

As a damper signal
If a line of 3 or more comparators are in a loop wherein two redstone connect one or more comparators, then the signal will weaken by 1 with each cycle therethrough until entirely dying.

As a clock
Whenever Signal A is connected with full strength and the output is forwarded to signal B and the comparator toggle is set to on, the device will act as a 1-clock.

As an inventory contents checker
If a comparator is placed next to a container, it will provide an output based on the percentage of used space in the container. This includes: regular/large/trapped Chest, Furnace, Dispenser, Hopper, Brewing Stand, Dropper, Jukebox, End Portal Frame, Cauldron, or a Detector Rail with a Minecart with Chest / Hopper on it. The comparator may be separated from the input by one solid block if the 3 blocks form a line, however redstone current from below the separator may interfere. See below for more info.

Inventory checking output
When a container is empty, the output is off.

When it is not empty, the output signal strength is calculated as follows:

Example: 300 blocks in a dispenser (which has 9 slots), where each block stacks to a maximum of 64, produces output with a signal strength of 8: 1 + ((300 items / 64 items per slot) / 9 slots) * 14 = 8.292, truncated is 8

Note that a non-stackable item is counted as a full slot (1 item in a slot, with a max stack size of 1: 1 / 1 = 1.0), and items which stack up to 16 (such as ender pearls and snowballs and eggs) are similarly considered a full slot at 16.

Specific output signal strength creation
It can be useful in redstone circuits to use containers with comparators to create signals of a specific strength. The number of items required in a container to produce a signal of desired strength is calculated as follows:

Example: To use a furnace (which has 3 slots) to create a strength 9 signal, you need 110 items: max(8, (3*64/14)*(9-1)) = 109.714, rounded up is 110

Power listings of a furnace
This table shows the number of full slots(e.g. non-stackables like shovels,...) and blocks/items(stackable to 64) needed to get a specific output strength when using a furnace. Minimum and maximum needed items are shown. The optimal column tries to round to the nearest number of full slots between the minimum and maximum, if that isn't possible it optimizes by splitting 64-stacks in half and so on. Basically it's easier to count and needs less clicks to get a number of blocks/items in the furnace. * Note that you have to smelt things to get items into the third slot, therefore using chests may be a better option if you want signal strength 11 or higher.

Power listings of a single chest
This table shows the number of full slots(e.g. non-stackables like shovels,...) and blocks/items(stackable to 64) needed to get a specific output strength when using a single chest. Minimum and maximum needed items are shown. The optimal column tries to round to the nearest number of full slots between the minimum and maximum.

By using the /give command, it is possible to get a stack that has more than the normal maximum for an item. For example, beds normally do not stack, however you can use /give  bed 27 to get a stack of 27 beds. If you put the resulting stack of 27 beds in a chest, it will then output a signal strength of 15. Using this technique, and increasing the number to greater than 27, you can create chests (and other containers) which are more than 100% full. While you cannot store a signal with strength larger than 15 in redstone wire, redstone comparators can internally have a strength of more than 15. This internal strength can then be subtracted to reach signal strengths that wire can carry. For example, if you put 29 beds in a chest, set a comparator examining the chest to subtraction mode, and subtract a signal of maximum strength (15), the comparator will output a signal strength of 1.

Jukebox record identification
Unlike most containers, the signal output by a jukebox represents the record it contains. It outputs:

Other Unique Block Outputs
End Portal Frame blocks output a full signal of 15 if they contain an Eye of Ender and zero otherwise.

Cauldrons output different signal strengths depending on how much water is inside. From completely empty to completely full, the output values are 0, 1, 2, and 3.

Command Block Output
Command Blocks output a property called "Success Count", which represents the number of times the most recently used command of this Command Block succeeded. A "success" is defined by the command's success conditions: if a red error message is returned, the command was not successful.

Most commands can only succeed once per execution, but certain commands (such as those which accept players as arguments) can succeed multiple times, and the comparator will output the number of times it succeeded (of course, this is capped at a full signal of 15, so it will output 15 if there were 15 or more successes). Examples of such commands are /tell and /testfor. Note that /say will never output more than 1, as the command only outputs one message in chat regardless of the number of players who are referenced (their names are merely formatted as a list of the form "name1, name2, and name3").

Note that the comparator will output the Command Block's success count for the last command executed: it will be a constant signal (or lack thereof) and will only update when the command is next executed.

Trivia

 * The comparator does not re-strengthen a redstone signal. This means it can not be used for super-long instant circuits.
 * If placed every second block between redstone, they can endlessly carry a signal, at same speed than repeaters on first setting, without it losing power strength. Placing a non-transparent block at every corner allows it to bend without losing power. It is also possible to reduce the needed amount of comparators further (and thus improve the signal speed) by facing the comparators into solid blocks behind which redstone is placed
 * A redstone comparator outputs a strong signal. This does not mean it resets the signal strength like repeaters, but it means the signal can be picked up through a block without using a repeater (Like a repeater)
 * If you join up the redstone torches, an arrow is created which points to the redstone output. This arrow can also be seen as a red triangle on the Comparator, if one looks hard enough.

Gallery
Redstone-Komparator Comparador de Redstone Comparateur Vöröskő-összehasonlító Komparator Компаратор 红石比较器