# Electronic – Addition and subtraction in digital electronics

digital-logicmath

Why is it that addition of the 2's complement is an efficient method of subtracting? Does this simplify the circuit?

As Olin pointed out in his comment, A - B and A + (-B) are the same thing, but note the latter actually uses addition.

So with 2's compliment, you only need one kind of circuit to do addition/subtraction, namely an adder (instead of an adder and a separate subtracter, plus the circuitry to switch the data bus back and forth between the two).

Taking the two's complement of a number involves first taking the 1's complement (toggling all of the bits, a trivial logic operation) and then adding one. The latter seems to require a separate adder to perform that step before adding the two operands, but we can get by with just one adder circuit by setting the carry in lead of the first bit of the adder to high when doing subtraction, and low when doing addition.

``````An example:    5 - 3

0101
-   0011
======
0010

same as:

0101
+  1100  (1's complement of 0011)
+     1  (carry-in)
======
0010

Just the opposite:  3 - 5

0011
-   0101
======
1110

same as:

0011
+  1010  (1's complement of 0101)
+     1  (carry-in)
======
1110
``````