Redstonery › Circuits › Comparator subtract
Detection circuit
Comparator subtract
Compute a nonnegative difference between signal strengths.
10 × 4 footprint1 layer13 blocksTested in 4 rotationsJava Edition 26.2
Layout
redstone dustrepeater or comparatorinputlamparrows point where a device sends its output; north is up
How it works
Subtract mode outputs front minus side: 10 minus a side of 14 is nothing; with the side off it is 10 again.
- Subtract mode takes the main strength minus the strongest side strength.
- A negative result becomes zero. The result is still a redstone strength, not a signed number.
Inputs and outputs
- Inputsignal (x 0, y 0, z 0)
- Inputsubtract 14 (x 7, y 0, z 3)
- Outputfront minus side (x 9, y 0, z 0)
Blocks you need
9 × redstone dust, 2 × lever, 1 × comparator, 1 × redstone lamp.
Build it in the game: 13 commands
Relative to where you stand, with x running east and z running south. Paste one line at a time into chat, or into a chain of command blocks. The block art is the game's own; the layout is what the page above shows.
setblock ~0 ~0 ~0 minecraft:lever[face=floor,facing=north,powered=true] setblock ~1 ~0 ~0 minecraft:redstone_wire setblock ~2 ~0 ~0 minecraft:redstone_wire setblock ~3 ~0 ~0 minecraft:redstone_wire setblock ~4 ~0 ~0 minecraft:redstone_wire setblock ~5 ~0 ~0 minecraft:redstone_wire setblock ~6 ~0 ~0 minecraft:redstone_wire setblock ~7 ~0 ~0 minecraft:comparator[facing=west,mode=subtract] setblock ~8 ~0 ~0 minecraft:redstone_wire setblock ~9 ~0 ~0 minecraft:redstone_lamp setblock ~7 ~0 ~3 minecraft:lever[face=floor,facing=north,powered=false] setblock ~7 ~0 ~2 minecraft:redstone_wire setblock ~7 ~0 ~1 minecraft:redstone_wire