Adder–subtractor

Below is a circuit that adds or subtracts depending on a control signal.

It is also possible to construct a circuit that performs both addition and subtraction at the same time.

Then to perform B − A, two's complement theory says to invert each bit of A with a NOT gate then add one.

Adders are a part of the core of an arithmetic logic unit (ALU).

A further step would be to change the 2-to-1 multiplex on A to a 4-to-1 with the third input being zero, then replicating this on Bi thus yielding the following output functions: By adding more logic in front of the adder, a single adder can be converted into much more than just an adder—an ALU.

A 4-bit ripple-carry adder–subtractor based on a 4-bit adder that performs two's complement on A when D = 1 to yield S = B A .