Subtract binary numbers - how it works
Related Videos: How To Subtract Binary Numbers (May 2024).
Binary numbers are easier to subtract than you might think. You don't need a calculator or a computer. You only need to master the basic arithmetic of mathematics.
Subtract binary numbers - how it works
To subtract binary numbers, you must first make a one's complement from the second binary number and then form a two's complement from it. Then you can simply add the two binary numbers to actually subtract them. That sounds a little complicated, but it's very simple.
- If two binary numbers are subtracted, the second number is simply converted somewhat. Then you can go the simple way of adding to find the difference between the two binary numbers.
- A binary number consists only of a sequence of zeros and ones. In the first step you have to make one's complement out of the second binary number. It's easy: Swap all zeros for ones and all ones for zeros.
- In the next step, you make a two's complement from this one's complement. Just add the number one. To do this, however, you need to know how to add binary numbers. We describe in detail how this can be done in another article.
- Now you have prepared the calculation so that you have made an addition from the subtraction - and can thus solve the task. The theory is sometimes a little more difficult to understand. We will therefore show you the invoice using an example in the next section.
Subtract binary numbers without a computer: A sample calculation
In this example, we go through the subtraction of the binary numbers 1011 and 0110 step by step, i.e. the calculation 1011 minus 0110. It is best to take a piece of paper with you to understand the calculation.
- Form a one's complement from the second binary number: 0110 -> 1001
- From this you add a two's complement by adding 1: 1001 + 1 = 1010
- To subtract 0110 from 1010, add the two's compliment of the second binary number to the first binary number. So the calculation is 1011 + 1010. According to the rules of adding binary numbers, you get the binary number 0101.