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.
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:
Math illustrated by the author
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:
Math illustrated by the author
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.
Math illustrated by the author
To drive home the point, here are a couple of similar examples that illustrate the algorithm:
Math illustrated by the author
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.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-advertisement
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category .
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
CookieLawInfoConsent
1 year
Records the default button state of the corresponding category & the status of CCPA. It works only in coordination with the primary cookie.
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Cookie
Duration
Description
_gat
1 minute
This cookie is installed by Google Universal Analytics to restrain request rate and thus limit the collection of data on high traffic sites.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Cookie
Duration
Description
__gads
1 year 24 days
The __gads cookie, set by Google, is stored under DoubleClick domain and tracks the number of times users see an advert, measures the success of the campaign and calculates its revenue. This cookie can only be read from the domain they are set on and will not track any data while browsing through other sites.
_ga
2 years
The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors.
_ga_R5WSNS3HKS
2 years
This cookie is installed by Google Analytics.
_gat_gtag_UA_131795354_1
1 minute
Set by Google to distinguish users.
_gid
1 day
Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously.
CONSENT
2 years
YouTube sets this cookie via embedded youtube-videos and registers anonymous statistical data.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Cookie
Duration
Description
IDE
1 year 24 days
Google DoubleClick IDE cookies are used to store information about how the user uses the website to present them with relevant ads and according to the user profile.
test_cookie
15 minutes
The test_cookie is set by doubleclick.net and is used to determine if the user's browser supports cookies.
VISITOR_INFO1_LIVE
5 months 27 days
A cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.
YSC
session
YSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.
yt-remote-connected-devices
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
yt-remote-device-id
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
Comments