How to Do Binary Subtraction


Subtracting two binary numbers is not much different than subtracting decimal (base 10) numbers like we all learned in elementary school. The concept of "borrowing" exists in binary subtraction just as in decimal subtraction, but this method can be difficult in binary subtraction. A much easier method is to use the "2's complement" technique. This involves a few steps, but the resulting process is easier than worrying about carrying bits in standard subtraction in the event you must "borrow."

Subtracting Numbers with an Equal Number of Bits

  • Assume an example problem of 10110011 - 00101101. The first step is to take the 1's complement of the number we are subtracting (00101101). The 1's complement is the exact inverse of the number meaning every 0 becomes a 1 and every 1 becomes a 0. In our example 00101101 becomes 11010010.

  • Create the 2's complement by adding 1 to the 1's complement. In our example this is 11010010 + 1 = 11010011.

  • Add the 2's complement number to the number we were going to subtract from. In our example this is 10110011 + 11010011 = 110000110. Notice there is one more bit of carry over after this addition, this carry over is thrown away so our result is 10000110.

Subtracting a Number with Fewer Bits from a Number with More Bits

  • Assume an example of 10110011 - 101010, in which we have 2 fewer bits in the number we are subtracting than the number we are subtracting from. In this case, we need to add as many leading 0's to the number so that it has the same number of bits before we perform the same 2's complement steps as above.

  • Add two leading zero's to 101010 so that it becomes 00101010.

  • Compute the 1's complement of 00101010, which becomes 11010101.

  • Compute the 2's complement by adding: 11010101 + 1 = 11010110

  • Complete the subtraction by adding 10110011 + 11010110 = 110001001. Again, throw away the carry over in the 9th bit so that the result is 10001001.

  • Photo Credit Jupiterimages/ Images
Promoted By Zergnet



You May Also Like

Related Searches

Read Article

Can You Take Advantage Of Student Loan Forgiveness?

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!