Michael
Michael

Reputation: 45

Why perform subtraction using addition?

I am curious about why we use addition to carry out subtraction in digital design systems.

I have a hunch that it has something to do with cost and performance but I don't understand how it would save money or be more efficient.

Upvotes: 1

Views: 431

Answers (1)

skrrgwasme
skrrgwasme

Reputation: 9633

This really breaks down into two questions:

Why not use dedicated circuits for each operation?

Every additional circuit in a design costs money and time to design, validate, and allocate budgets for space, power and timing. We will (almost) always come out ahead if we can design a single circuit that can handle multiple operations.

In digital circuits, "a + b" and "a - b" are two different operations that require different circuits. Fortunately though, in arithmetic, "a + b" is the same as "a + (-b)", so the math doesn't care which one we use. Some very smart people came up with a clever representation for signed numbers that takes advantage of this mathematical fact, called Two's Complement. This representation allows positive and negative numbers to be added and inverted easily.

Since we can now implement both addition and subtraction with one circuit, there's no point to creating a second one.

Okay, so why addition?
If the operations are now interchangeable, why did we implement everything in addition instead of subtraction? I can only speculate on this, but I suspect the following reasons:

An adder circuit is less complicated than a subtractor:

Half Adder:

enter image description here

Half Subtractor:

enter image description here

Note that the subtractor has an added inverter. Every transistor counts in a digital design, so all other things being equal, we should use the circuit with fewer components.

Furthermore, addition is simply a more common operation. Incrementing instruction pointers & other memory addresses, iterator/loop indexes, and other regularly formed values is much more common than stepping backwards. If we're choosing to either handle subtraction or addition natively (which we are, since we are only going to dedicate one circuit to both), then it makes sense to choose the most common one. Now we've added an extra step to subtraction operations (convert to two's complement), but it's preferable to adding an extra step to the more common addition operations.

Further Reading
There is a very similar quesiont on EE.SE: Addition and subtraction in digital electronics

Here on SO: What is “2's Complement”?

Upvotes: 1

Related Questions