Imagine that you are required to subtract using addition only. I can already guess your first impression about such a task. Any typical person would react along the following lines:
“Why on earth do I need to subtract using addition only? What is wrong with subtraction? It exists for a reason! Isn’t this akin to engaging in a boxing match with one hand tied behind the back?”
Well, I concede that this task does indeed sound very impractical on the surface. However, there exist very practical utilities to such an approach to subtraction.
In this article, I will cover the motivation behind this task first. Then, I will illustrate an algorithm that subtracts by addition only in the conventional decimal (base ten) system. After this, I will touch upon the broader concept that underlies the illustrated algorithm. And finally, I will try to generalize the problem statement and solution for broader computational systems.
This essay is supported by Generatebg
Why Subtract Using Addition Only?
Before the invention of modern technologies, complex calculations were done using mechanical means. Manufacturers and inventors of mechanical calculators were able to save on components (count) by implementing algorithms that used addition only. This led to compact and cost-efficient devices.
In fact, the digitization of technology did not change the fundamental dynamics in this context very much. If transistors are considered switches (because of their binary ON/OFF states), an algorithm that enables us to subtract using addition would result in similar compactness and cost-effectiveness of digitized computational devices as well. So, it is no wonder that subtraction using addition is ubiquitous even in the modern digital world.
An Illustrated Example of Subtraction using Addition Only
Instead of diving into the theoretical concept behind a subtraction algorithm only using addition, it is beneficial if we start with an illustrated example first. Let us say that we need to compute (25689–12865). Conventionally, we would perform the subtraction operation as follows:
This is the standard algorithm all of us learn in school. So, how could we achieve the same result using addition? Well, check this out:
It is clear that I performed addition there. But there are a couple of questions that come up straight away.
How did I know which number to add to the number 25689?
And why did I neglect the leftmost ‘1’ from the result of addition?
In order to answer these questions, let’s jump straight into the mechanics of the algorithm that I used.
The Algorithm to Subtract using Addition
To understand what is going on, let us deconstruct the task into the minuend (the number from which we subtract) and the subtrahend (the number which we subtract). It is clear that I replaced the subtrahend with an addend (a number that is to be added).
So, the algorithm that I used pretty much switches the subtrahend with an addend. The next step is to figure out how this is done. To put it in simple terms, I take the subtrahend and subtract each digit except the last digit from ‘9’. Then, I subtract the last digit from ‘10’. This gives me the addend. Finally, I just neglect or ignore the very first digit that occurs in the result of the addition operation. This gives me the result of the subtraction operation.
If you find this description too wordy, worry not! Just check out the mathematical illustration below, and it should be straightforward.
To drive home the point, here are a couple of similar examples that illustrate the algorithm:
Now that we have seen how this algorithm works, it is time to answer why this algorithm works.
The Method of Compliments
The mathematical framework behind the algorithm I illustrated is known as the method of compliments. In simple terms, each number has a unique compliment given a base framework. In this method, we take advantage of two factors.
1. The Fact that subtraction can be represented as addition of a negative number. For example: (5–3) = 5 + (- 3), and
2. For any base-system (the decimal system in the illustrated example), one can pre-encode additive inversion of each digit.
In the illustrated example, we take the subtrahend and calculate the nine’s complement for each digit except the last one. For the last digit, we calculate the ten’s compliment.
At the end of the addition process, we end up with one digit above the necessary significance level. This is the leftmost digit that we discard at the end. In computer science terms, we call this ‘overflow’. Mathematically, this approach is described using modular arithmetic.
I wouldn’t blame you if you were sceptical about the validity of the claim of ‘subtraction by addition’. In the algorithm that I illustrated, we clearly subtract on each instance when we compute the compliment (to get the addend). Here, it is important to realise that the compliment for each digit can be pre-computed, hard-encoded, and referenced. So, when the algorithm is being executed, there is no explicit subtraction needed anymore.
Generalizing To Broader Computational Systems
In the beginning of the article, I mentioned that even modern computers subtract using addition. Digital computers operate under the same principles. The only difference in the binary system is that the algorithms compute two’s compliment in place of nine’s compliment.
The algorithm that I illustrated in this article is not the only possible algorithm to subtract using addition. There are several possible algorithms, and the mathematical generalization is achieved by a concept known as Radix Compliment.
There you have it. An approach to subtract using addition might sound absurd when we calculate small numbers by hand. But when it comes to automated computation (both by mechanical as well as digital machines), not only is subtraction by addition the norm, but it is also a resource-efficient solution!
Credit: Some of my illustrations in this article were inspired by the work done by Henry Reich.
I hope you found this article interesting and useful. If you’d like to get notified when interesting content gets published here, consider subscribing.
Further reading that might interest you: How Much String Would You Need To Wrap The Earth? and How To Hear Acceleration Without Modern Technology?
Comments