Binary Subtraction
Binary subtraction is the process of subtracting binary numbers. Binary numbers include only 0 and 1. The process of binary subtraction is the same as the arithmetic operation of subtraction that we do with numbers. Since only 0 and 1 are involved here, we may sometimes need to subtract 0 from 1. In such cases, we use the concept of borrowing as we do in an arithmetic subtraction. A binary number is expressed with a base-2. For example, a binary number is written as \(101_{2}\)
Rules of Binary Subtraction
There are some rules in which binary numbers are subtracted. They are,
How To Do Binary Subtraction?
Decimal or base-10 numbers can be expressed as binary numbers. Binary numbers are used in computers to represent data since they understand only binary digits, 0 and 1. Let us understand how to subtract binary numbers with the example shown below.
Case i) - Binary subtraction without borrowing
Subtract \(100_{2}\) from \(1111_{2}\) .Here number 4 is represented in binary as \(100_{2}\) and number 15 is represented as \(1111_{2}\).
Step 1: Arrange the numbers as shown in the figure below.
Step 2: Follow the binary subtraction rules to subtract the numbers. In this subtraction, we do not encounter the subtraction of 1 from 0. Hence, the difference is \(1011_{2}\).
Step 3: The decimal equivalent of \(1011_{2}\) is 11. Hence the difference is correct.
Case ii) Binary subtraction with borrowing
Subtract \(101_{2}\) from \(1001_{2}\). Here number 5 is represented in binary as \(101_{2}\) and number 9 is represented as \(1001_{2}\).
Step 1: Arrange the numbers as shown below.
Step 2: Follow the binary subtraction rules to subtract the numbers. In this subtraction, first, let us subtract the numbers starting from the right and move to the next higher order digit. The first step is to subtract (1-1). This is equal to 0. Similarly, we move on to the next higher order digit and subtract (0 - 0), which is 0. In the next step, we have to subtract (0 - 1), so we borrow a 1 from the next higher order digit. Therefore, the result of subtracting (0 - 1) is 1.
Step 3: Therefore the dfference of \(1001_{2}\) and \(101_{2}\) is \(100_{2}\). To verify this, let us find the decimal equivalent of \(100_{2}\), which is 4, Therefore, 9 - 5 = 4.
Binary Subtraction Using 1's Complement
The 1's complement of a number is obtained by interchanging every 0 to 1 and every 1 to 0 in a binary number. For example, the 1's complement of the binary number \(110_{2}\) is \(001_{2}\). To perform binary subtraction using 1's complement, please follow the steps mentioned below.
- Step 1: Find the 1's complement of the subtrahend, which means the second number of subtraction.
- Step 2: Add it with the minuend or the first number.
- Step 3: If there is a carryover left then add it with the result obtained from step 2.
- Step 4: If there are no carryovers, then the result obtained in step 2 is the difference of the two numbers using 1's complement binary subtraction.
Let us understand this with an example.Subtract \(110010_{2}\) - \(100101_{2}\) using 1's complement. Here the binary equivalent of 50 is \(110101_{2}\) and the binary equivalent of 37 is \(100101_{2}\).
Step 1: Find out the 1's complement of the subtrahend (37), which is \(011010_{2}\).
Step 2: Add it with the minuend(50), which is \(110010_{2}\).
Step 3: Arrange the numbers as follows and add them.
Step 4: The left-most digit 1 is a carryover of this addition. Since there is a carryover we add it with the result, which is \(001100_{2}\).
Therefore, the result is \(1101_{2}\). Also, the difference of 50 - 37 is 13. The binary equivalent of 13 is \(1101_{2}\).
Related Topics
Check out some interesting topics related to binary subtraction.
Binary Subtraction Examples
-
Example 1: Subtract \(1101_{2}\) from \(10110_{2}\).
Solution:
Step 1: Arrange the numbers as shown below.
1 0 1 1 0
- 1 1 0 1
---------------
_________Step 2: Start subtracting from the right. Starting to subtract from the rightmost position, we begin with (0 - 1). Since 0 - 1 can not be done, we borrow a 1 from the next higher order digit. So the result of (0 - 1) is now 1. Since we have borrowed the 1 from the next higher order digit, the 1 has become 0. We know that (0 - 0) is 0. Now, move on to the next higher order digit, wherein we have to subtract (1 - 1), which is 0. The next higher order digit has (0 - 1), for which we need to borrow a 1. On borrowing, we obtain the result as 1. Therefore, the difference is equal to \(1001_{2}\).
1 0 1 1 0
- 1 1 0 1
-----------------
1 0 0 1
__________
Step 3: The decimal equivalent of \(10110_{2}\) is 22 and the decimal equivalent of \(1101_{2}\) is 13. Therefore the result is 9. The binary equivalent of 9 is \(1001_{2}\).
-
Example 2: Subtract \(100010_{2}\) from \(110101_{2}\) using 1's complement method of binary subtraction.
Solution:
Step 1: Find the 1's complement of the subtrahend, which is \(100010_{2}\). The 1's complement is \(011101_{2}\) .
Step 2: Add it with the minuend.
Step 3:
0 1 1 1 0 1
+ 1 1 0 1 0 1
-------------------
1 0 1 0 0 1 0
--------------------Step 4: Here we get the last left-most digit 1 as a carryover. Now, we add it with the result obtained in step 3.
Step 5: Therefore, we get,
0 1 0 0 1 0
+ 1
----------------
0 1 0 0 1 1
----------------The decimal equivalent of \(100010_{2}\) is 53 and the decimal equivalent of \(110101_{2}\) is 34. Therefore the result is 19. The binary equivalent of 19 is \(10011_{2}\).
FAQs on Binary Subtraction
How to Subtract Binary Numbers?
Binary subtraction can be performed by the normal borrow method of arithmetic subtraction or by finding the 1's complement of the subtrahend and adding it with the minuend and add carryovers if any with the sum.
What are the Rules for Binary Subtraction?
The following rules are to be followed before we subtract two binary numbers. They are,
- 1 - 0 = 1
- 1 - 1 = 0
- 0 - 0 = 0
- 0 - 1 = 1 (This can not be done directly, hence we borrow a 1 from the next higher order digit.)
What Do You Mean by 1's Complement?
1's complement of a number is replacing every 0 with a 1 and every 1 with a 0 in a binary number. For example, the 1's complement of \(101_{2}\) is \(010_{2}\).
How Do You Borrow in Binary Subtraction?
Borrowing is done in binary subtraction when we encounter a situation of subtracting 1 from 0. In that case, we borrow a 1 from the next higher digit and perform the subtraction. Therefore, 0 - 1 gives us 1.
What is Binary Number System?
The Binary number system is a type of number system which uses only two digits, 0 and 1. Computers use binary digits to store all types of information. We can perform arithmetic operations like addition and subtraction in the binary number system.
visual curriculum