Subtracting binary numbers is a little different from subtracting decimal numbers. If you need to do something like that, follow the steps in this article so you don't have any difficulties!
Steps
Method 1 of 2: Using the Loan Method
Step 1. Align the numbers as if you were going to do normal subtraction
Put the largest term above the smallest one, and if it has a smaller number of digits, put it to the right - as you would with subtracting decimal numbers (from base ten).
Step 2. Try to solve some basic problems
Certain questions involving binary numbers are equal to subtraction of base ten decimals. Align terms in columns and find the results for each digit starting from the right. See these examples:
- 1 - 0 = 1
- 11 - 10 = 1
- 1011 - 10 = 1001
Step 3. Try to solve a more complicated problem
To do this, just follow this tip: "borrow" a digit that is on the left to solve a column "0 - 1". The rest of this section provides some examples of problems and ways to solve them with the loan method. The first is:
-
110 - 101 = ?
Step 4. Take a "borrowed" digit from the second term
Starting in the right column (where the first values are), solve the problem "0 - 1". To do this, borrow a number from the digit on the left (where the second values are). Follow the next two steps:
- First, cut the 1 and replace it with 0, leaving you with the following: 1010 - 101 = ?
-
So, you'll subtract 10 from the first number so you can add the following term "borrowed" to the vacant place: 101100 - 101 = ?
Step 5. Solve the column on the right
Now you can solve the rest of the problem normally. Follow the steps below to solve the right part (where the first values are) in the following example:
- 101100 - 101 = ?
- So, the right column will look like this: 10 - 1 = 1. If you can't get that answer, read this article to convert the values to decimal numbers:
- 102 = (1 x 2) + (0 x 1) = 210. (values demoted represent the base of the number)
- 12 = (1x1) = 110
- So, in decimal form, this problem would be: 2 - 1 = ? (answer: 1)
Step 6. Finish the resolution
From that point on, it will be easy to continue. Scroll from column to column, right to left:
-
101100 - 101 = _1 = _01 = 001 =
Step 1.
Step 7. Try to solve a more difficult problem
The borrowing technique is very common in the multiplication of binary numbers, and thus it can be used several times in the same column. Below, for example, is the resolution of 11000 - 111. You can't borrow anything from a zero; therefore, you'll have to keep taking items from the left until you reach something you can finally remove a number from:
- 10110000 - 111 =
- 10111001000 - 111 = (remember, 10 - 1 = 1)
- 10111001100100 - 111 =
- If better organized, the expression looks like this: 1011100 - 111 =
- Solve one column at a time: _ _ _ _ 1 = _ _ _ 0 1 = _ _ 0 0 1 = _ 0 0 0 1 = 1 0 0 0 1
Step 8. See if the answers are right
There are three methods for doing this check. The most practical of these is to enter the problem into a virtual calculator. The other two are also useful, although you may still have to do a manual data check - which ultimately makes any user more accustomed and comfortable with binary numbers.
- Add the binary numbers together to see if you got it right. Add the answer to the smaller number - if it's correct, you'll get the larger term. Following the above example (11000 - 11 = 10001), I would look like 10001 + 111 = 11000 (ie, the longest term).
- You can also convert each binary number to decimal to test the answer. Using the same example (11000 - 111 = 10001), you would get 24 - 7 = 17 (correct).
Method 2 of 2: Using the Add-on Method
Step 1. Align the two numbers as if you were subtracting decimals
Many computers use this method as it can make programs more efficient. For those not used to such problems, this is probably the most difficult alternative (although it can be simple for programmers).
-
Here, there is the example 101 - 11 = ?
Step 2. If necessary, write the leading zeros of the numbers to represent both with the same number of digits
For example: convert 101-11 to 101-011.
-
101 - 011 = ?
Step 3. Swap the digits of the second term
Change every zero to 1 (and vice versa). In the example above, you would look like this: 011 → 100.
-
Simply put, in this step, just subtract 1 from each digit of the term. This "swap" works on binary numbers, as the only possibilities are the following: 1 - 0 =
Step 1. and 1
Step 1. = 0.
Step 4. Add 1 to the new second term
After reversing the order of the numbers, add this sum. The example of this method would be: 100 + 1 = 101.
Step 5. Solve the new problem as if it were a matter of adding binaries
Use the techniques you've learned to add terms to the original rather than subtract:
- 101 + 101 = 1010
- If none of this makes sense to you, read this article one more time.
Step 6. Erase the first digit
With this method, the operation response will always have an extra term. In the example above, even though the numbers have three digits (101 + 101), there would still be four left at the end (1010). Just cut the extra term to get to the answer of the subtraction original:
- 1 010 = 10
- Therefore, 101 - 011 = 10
- If you don't get the extra digit at the end, it's because you tried to subtract the larger number from the smaller number. Read the tips below to learn how to resolve these issues and start over.
Step 7. Try this method using base ten
This is called "two's complement", since the alternative of reversing the digits is called "one's complement" (when adding the number 1). If you want to understand how it works more intuitively, use the tenth base:
- 56 - 17
- Since, in the example, you have base ten, use the "complement to nine" of the second term (17), subtracting 9 from each digit. That is: 99 - 17 = 82.
- Turn this into an addition problem: 56 + 82. If you compare these terms to the original problem (56 - 17), you will see that you add up to 99.
-
56+82= 138.
However, since the changes to the example left the original problem with 99 more numbers, you'll have to subtract that same amount from the answer. Use a shortcut, just like in the binary method above: add 1 to the total number and then delete the left digit (which represents 100):
- 138 + 1 = 139 → 139 → 39 Ready! This is the solution to the original problem, 56-17.
Tips
- To subtract a larger number from a smaller one, switch the order of terms, perform the operation, and then put a minus sign on the answer. For example: to solve binary problem 11 - 100, write the data as 100 - 11 and finally put "-" in front of the result. This rule applies to the subtraction of any base, binary or not.
- Mathematically, the add-on method uses the property a - b = a + (2 - b) - 2 . When n is the number of digits in b, 2 - b is one more value than the result of the negation.