Subtraction using Logic Gates
Consider the circuit below:
The circuit has two outputs labelled DIFF and BORROW. A truth table for the circuit looks like:
Cleary this circuit is performing binary subtraction of B from A (A-B, recalling that in binary 0-1 = 1 borrow 1). Such a circuit is called a half-subtractor, the reason for this is that it enables a borrow out of the current arithmetic operation but no borrow in from a previous arithmetic operation.
As in the case of the addition using logic gates, a full subtractor is made by combining two half-subtractors and an additional OR-gate. A full subtractor has the borrow in capability (denoted as BORIN in the diagram below) and so allows cascading which results in the possibility of multi-bit subtraction. The circuit diagram for a full subtractor is given below.
The final truth table for a full subtractor looks like:
For a wide range of operations many circuit elements will be required. A neater solution will be to use subtraction via addition using complementing as was discussed in the Binary Arithmetic topic. In this case only adders are needed.