Subtracting binary numbers is very similar to adding them, except now instead of carrying we are going to need to borrow.
Let’s subtract down from 8
and until we reach 4
.
Decimal | Binary |
---|---|
8 - 1 = 7 | 1000 - 1 = 111 |
7 - 1 = 6 | 111 - 1 = 110 |
6 - 1 = 5 | 110 - 1 = 101 |
5 - 1 = 4 | 101 - 1 = 100 |
Here are some rules for subtraction:
1 - 0 = 1
10 - 1 = 1
11 - 1 = 10
The key to any math problem is to take your time and check your work often. Subtraction is typically slightly more difficult simply because of borrowing and keeping track of the borrowed digits.
While not as important in addition, it is paramount in subtraction to place the larger number on top of the subtraction. If not, the result will be a negative number.
Here is an example of subtraction, pay close attention to how the borrowing in binary works out and try it out on simple problems first!
Ex. Subtracting 11
2 from 11010
2:
Binary | Decimal | 11010 | 26 - 11 | - 3 ------ | --- 10111 | 23
In decimal subtraction, you would borrow from the next digit. If the next value was a 7
, you would cross it out, make it a 6
, and bring the 1
over to your current subtraction.
In binary subtraction you do the same thing except you can only ever borrow from a 1
and it will always go to 0
. Just like in decimal, if the next digit is a 0
, you have to go to the next 1
and carry all the way down the numbers.
Instructions
Create the variable, answer1
, and set it equal to the result of 101
2 - 1
2.
*Note: Using a sheet of scratch paper can help significantly with keeping your math in order.
Create another variable, answer2
, and set it equal to the result of 10010
2 - 1011
2.
Create the final variable, answer3
, and set it equal to the result of 1110111011
2 - 11010111
2.