The half subtractors can be designed through the combinational Boolean logic circuits [2] as shown in Figure 1 and 2. The half subtractor is a combinational circuit which is used to perform subtraction of two bits. It has two inputs, the minuend X {\displaystyle X} and subtrahend Y {\displaystyle Y} and two outputs the difference D {\displaystyle D} and borrow out B out {\displaystyle B_{\text{out}}} . The borrow out signal is set when the subtractor needs to borrow from the next digit in a multi-digit subtraction. That is, B out = 1 {\displaystyle B_{\text{out}}=1} when X < Y {\displaystyle X<Y} . Since X {\displaystyle X} and Y {\displaystyle Y} are bits, B out = 1 {\displaystyle B_{\text{out}}=1} if and only if X = 0 {\displaystyle X=0} and Y = 1 {\displaystyle Y=1} . An important point worth mentioning is that the half subtractor diagram aside implements X − Y {\displaystyle X-Y} and not Y − X {\displaystyle Y-X} since B out {\displaystyle B_{\text{out}}} on the diagram is given by
This is an important distinction to make since subtraction itself is not commutative, but the difference bit D {\displaystyle D} is calculated using an XOR gate which is commutative.
The truth table for the half subtractor is:
Using the table above and a Karnaugh map, we find the following logic equations for D {\displaystyle D} and B out {\displaystyle B_{\text{out}}} :
Consequently, a simplified half-subtract circuit, advantageously avoiding crossed traces in particular as well as a negate gate is:
where lines to the right are outputs and others (from the top, bottom or left) are inputs.
The full subtractor is a combinational circuit which is used to perform subtraction of three input bits: the minuend X {\displaystyle X} , subtrahend Y {\displaystyle Y} , and borrow in B in {\displaystyle B_{\text{in}}} . The full subtractor generates two output bits: the difference D {\displaystyle D} and borrow out B out {\displaystyle B_{\text{out}}} . B in {\displaystyle B_{\text{in}}} is set when the previous digit is borrowed from X {\displaystyle X} . Thus, B in {\displaystyle B_{\text{in}}} is also subtracted from X {\displaystyle X} as well as the subtrahend Y {\displaystyle Y} . Or in symbols: X − Y − B in {\displaystyle X-Y-B_{\text{in}}} . Like the half subtractor, the full subtractor generates a borrow out when it needs to borrow from the next digit. Since we are subtracting Y {\displaystyle Y} and B in {\displaystyle B_{\text{in}}} from X {\displaystyle X} , a borrow out needs to be generated when X < Y + B in {\displaystyle X<Y+B_{\text{in}}} . When a borrow out is generated, 2 is added in the current digit. (This is similar to the subtraction algorithm in decimal. Instead of adding 2, we add 10 when we borrow.) Therefore, D = X − Y − B in + 2 B out {\displaystyle D=X-Y-B_{\text{in}}+2B_{\text{out}}} .
The truth table for the full subtractor is:
Therefore the equation is:
D = X ⊕ Y ⊕ B i n {\displaystyle D=X\oplus Y\oplus B_{in}}
B o u t = X ¯ B i n + X ¯ Y + Y B i n {\displaystyle B_{out}={\bar {X}}B_{in}+{\bar {X}}Y+YB_{in}}