User:HaydenBobMutthew/Mathematical analog circuit

A mathematical signal strength circuit is a circuit which operates on signal strength, such as arithmetic and comparison.

Basics
Since there is no redstone adder in Minecraft, we need to convert addition into subtraction.

a + b = a + b - 15 + 15 = - 15 + a + b + 15 = - (15 - a - b) + 15 = 15 - (15 - a - b)

However, as signal strength cannot be higher than 15, we need to have sum and carry out on the adder. Then we have:

sum = / a + b if a + b < 16 \ a + b - 16 if a + b ≥ 16 = / 15 - (15 - a - b) if a + b < 16 (hereinafter omitted) \ a + b - 15 - 1 if a + b ≥ 16 = a - 15 + b - 1 = - (15 - a) + (b - 1) = (b - 1) - (15 - a)

In an adder, there is also a carry in input, so we have the following equations: sum = a + b + c    = / 15 - (15 - a - b - c) if a + b + c < 16 (hereinafter omitted) \ (b + c - 1) - (15 - a) if a + b + c ≥ 16 = (b - 1 + c) - (15 - a)    = b - (1 - c) - (15 - a)

If a + b + c > 15, 15 - (15 - a - b - c) will be 15 in terms of comparators. If a + b + c < 16, b - (1 - c) - (15 - a) will be 0 in terms of comparators.