In
electronics
The field of electronics is a branch of physics and electrical engineering that deals with the emission, behaviour and effects of electrons using electronic devices. Electronics uses active devices to control electron flow by amplification ...
, a subtractor – a
digital circuit In theoretical computer science, a circuit is a model of computation in which input values proceed through a sequence of gates, each of which computes a function. Circuits of this kind provide a generalization of Boolean circuits and a mathematica ...
that performs subtraction of numbers – can be designed using the same approach as that of an
adder
Adder may refer to:
* AA-12 Adder, a Russian air-to-air missile
* Adder (electronics), an electronic circuit designed to do addition
* Adder Technology, a manufacturing company
* Armstrong Siddeley Adder, a late 1940s British turbojet engine
* ''B ...
. The
binary
Binary may refer to:
Science and technology Mathematics
* Binary number, a representation of numbers using only two digits (0 and 1)
* Binary function, a function that takes two arguments
* Binary operation, a mathematical operation that ta ...
subtraction process is summarized below. As with an adder, in the general case of calculations on multi-bit numbers, three
bit
The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented a ...
s are involved in performing the subtraction for each bit of the
difference
Difference, The Difference, Differences or Differently may refer to:
Music
* ''Difference'' (album), by Dreamtale, 2005
* ''Differently'' (album), by Cassie Davis, 2009
** "Differently" (song), by Cassie Davis, 2009
* ''The Difference'' (al ...
: the
minuend
Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
(
),
subtrahend
Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
(
), and a borrow in from the previous (less significant) bit order position (
). The outputs are the difference bit (
) and borrow bit
. The subtractor is best understood by considering that the subtrahend and both borrow bits have negative weights, whereas the X and D bits are positive. The operation performed by the subtractor is to rewrite
(which can take the values -2, -1, 0, or 1) as the sum
.
:
:
Subtractors are usually implemented within a binary adder for only a small cost when using the standard
two's complement
Two's complement is a mathematical operation to reversibly convert a positive binary number into a negative binary number with equivalent (but negative) value, using the binary digit with the greatest place value (the leftmost bit in big- endian ...
notation, by providing an addition/subtraction selector to the carry-in and to invert the second operand.
:
(definition of two's complement notation)
:
Half subtractor

The half subtractor is a
combinational circuit
In automata theory, combinational logic (also referred to as time-independent logic or combinatorial logic) is a type of digital logic which is implemented by Boolean circuits, where the output is a pure function of the present input only. This i ...
which is used to perform subtraction of two bits. It has two inputs, the
minuend
Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
and
subtrahend
Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
and two outputs the difference
and borrow out
. The borrow out signal is set when the subtractor needs to borrow from the next digit in a multi-digit subtraction. That is,
when
. Since
and
are bits,
if and only if
and
. An important point worth mentioning is that the half subtractor diagram aside implements
and not
since
on the diagram is given by
:
.
This is an important distinction to make since subtraction itself is not
commutative
In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Most familiar as the name o ...
, but the difference bit
is calculated using an
XOR gate
XOR gate (sometimes EOR, or EXOR and pronounced as Exclusive OR) is a digital logic gate that gives a true (1 or HIGH) output when the number of true inputs is odd. An XOR gate implements an exclusive or (\nleftrightarrow) from mathematical log ...
which is commutative.

The
truth table
A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra (logic), Boolean algebra, boolean functions, and propositional calculus—which sets out the functional values of logical expression (mathematics) ...
for the half subtractor is:
Using the table above and a
Karnaugh map
The Karnaugh map (KM or K-map) is a method of simplifying Boolean algebra expressions. Maurice Karnaugh introduced it in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which was a rediscovery of Allan Marquand's 1881 ''logic ...
, we find the following logic equations for
and
:
:
:
.
Consequently, a simplified half-subtract circuit, advantageously avoiding crossed traces in particular as well as a negate gate is:
X ── XOR ─┬─────── , X-Y, , is 0 if X equals Y, 1 otherwise
┌──┘ └──┐
Y ─┴─────── AND ── borrow, is 1 if Y > X, 0 otherwise
where lines to the right are outputs and others (from the top, bottom or left) are inputs.
Full subtractor
The full subtractor is a
combinational circuit
In automata theory, combinational logic (also referred to as time-independent logic or combinatorial logic) is a type of digital logic which is implemented by Boolean circuits, where the output is a pure function of the present input only. This i ...
which is used to perform subtraction of three input
bit
The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented a ...
s: the minuend
, subtrahend
, and borrow in
. The full subtractor generates two output bits: the difference
and borrow out
.
is set when the previous digit is borrowed from
. Thus,
is also subtracted from
as well as the subtrahend
. Or in symbols:
. Like the half subtractor, the full subtractor generates a borrow out when it needs to borrow from the next digit. Since we are subtracting
and
from
, a borrow out needs to be generated when
. 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,
.

The truth table for the full subtractor is:
Therefore the equation is:
See also
*
Adder (electronics)
An adder, or summer, is a digital circuit that performs addition of numbers. In many computers and other kinds of processors adders are used in the arithmetic logic units (ALUs). They are also used in other parts of the processor, where they are ...
*
Carry-lookahead adder
A carry-lookahead adder (CLA) or fast adder is a type of electronics adder used in digital logic. A carry-lookahead adder improves speed by reducing the amount of time required to determine carry bits. It can be contrasted with the simpler, b ...
*
Carry-save adder
*
Adding machine
An adding machine is a class of mechanical calculator, usually specialized for bookkeeping calculations.
In the United States, the earliest adding machines were usually built to read in dollars and cents. Adding machines were ubiquitous of ...
*
Adder-subtractor
References
* Foundations Of Digital Electronics by Elijah Mwangi
External links
N bit Binary addition or subtraction using single circuit.
Arithmetic logic circuits
4
Subtraction
Binary arithmetic
{{CPU technologies, state=collapsed