Computers cannot subtract so we use a mathematical "trick" so that we only add binary numbers together.
The trick involves taking the 2's compliment of the number we are subtracting. This can easily be done by "flipping" each of the binary digits (1 becomes a 0; 0 becomes 1) and then adding a 1 to the right-hand digit.
Consider the decimal number 3310 which in binary is: 0010 00012 flipping the bits gives 1101 11102 and now adding 1 gives: 1101 11112 which is the 2's compliment representation.
Let's do the calculation: 3910 - 3310.
3910 is 0010 01112 and to do this subtraction we add the 2's compliment value of the subtractor.
- 3310 is 01101 11112
So 3910 - 3310 is 0010 01112 + 1101 11112
We now apply a simple algorithm:
IF the number has a leading 1
THEN removing this gives the final solution
ELSE
Evaluate the 2’s compliment of this number and
add a minus sign to get the final solution.
Since we have a 1 in the final column when this is removed we get our answer: 0000 01102 or 610.
There are several Web sites that can help with the evaluation of 2's compliment. This is one that I found most useful: