Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives
_____________________________________________
Associated Topics || Dr. Math Home || Search Dr. Math
_____________________________________________

Binary Subtraction


Date: 7/25/96 at 15:27:39
From: Norman or Gwen Houston
Subject: Binary Subtraction

Dr. Math, 

Please explain and show examples of how to subtract in binary.  
I understand the rules of adding, but how in the world do you 
subtract?

Thank you,

Gwen Houston


Date: 7/25/96 at 19:9:53
From: Doctor Robert
Subject: Re: Binary Subtraction

Actually, you subtract in binary pretty much the same way that you do
in base 10.  You subtract digit by digit starting on the right side.  
If the subtraction cannot be made (for example, you cannot subtract 1 
from 0), you must then "borrow", just as you do in base 10 
subtraction.  But when you borrow a "one" from the 4's digit, it 
turns into two 2's.  This borrowing by two's (rather than 10's) is 
what makes it quite different from base 10 subtraction.  Perhaps an 
example is in order:

  10101
-  1011

Starting on the right, 1-1 = 0, so the rightmost digit in the answer 
is 0.  Moving left, we cannot subtract the 1 from the 0 (in the 2's 
position), so we borrow on from the 4's position giving us TWO 2's. 
Then 2-1 = 1 so that there is a 1 in the 2's position of the answer. 
Moving left 0-0=0 (remember we already borrowed the 1 in the 4's 
position of the top number) So 0 is the answer digit in the 4's 
position.  Moving left, we cannot subtract 1 from 0 so we borrow a 1 
from the 16's position giving us 2 in the 8's position.  2 - 1 = 1 so 
the answer is 1010.

It would look like this when you are done

  10101
-  1011
  -----
   1010

Just to check, in base 10 this would be 21 - 11 = 10.  It checks!
Hope that this helps.

-Doctor Robert,  The Math Forum
 Check out our web site!  http://mathforum.org/dr.math/   


Date: 7/25/96 at 20:13:50
From: Doctor Anthony
Subject: Re: Binary Subtraction

You can use the same method as subtracting in base 10, except that the 
carry takes place when you subtract 1 from 0, (which is made up to 2 
by borrowing from the column next on the left).  However a method of 
subtraction, by adding the 'complement' is particularly easy in binary 
arithmetic.

To complement a number in base 10, you subtract from a row of 9's.  
Likewise in base 2, the complement is obtained by subtraction from a 
row of 1's;

e.g. the complement of 10011101011
                    is 01100010100

All you have to do, in fact, is interchange 0's and 1's.

It is important, however, that before you complement a number which 
has to be subtracted, you add leading zeros to make it up to the same 
number of digits as the number from which you will be subtracting.  
There is a further problem concerning a 'carry' digit at the extreme 
left after adding the complement, but I will show you the method in an 
example.

Example: Find   1101011001 
              - 0010111010   (note the leading zeros)

Complement the second row and add:

                1101011001
              + 1101000101
               ------------
             (1)1010011110        


Now you notice that there is an embarrassing (1) at the left of the 
row. The rule now is to take this 1 across to the first column on the 
right and add it there, as shown below:

                1010011110
                         1
                -----------
                1010011111

That completes the subtraction. With practice, the method of 
subtraction by adding the complement is quicker and less error-prone, 
but it is of course a matter of choice.


-Doctor Anthony,  The Math Forum
 Check out our web site!  http://mathforum.org/dr.math/   


Date: 7/26/96 at 4:31:58
From: Norman or Gwen Houston
Subject: Re: Binary Subtraction

Dr. Math,

Thank you so much for your informative answer and examples.  This
information has helped me better understand the subtraction process of
binary numbers.

Regards,

Gwen Houston
    
Associated Topics:
High School Number Theory

Search the Dr. Math Library:


Find items containing (put spaces between keywords):
 
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

_____________________________________
Math Forum Home || Math Library || Quick Reference || Math Forum Search
_____________________________________

Ask Dr. MathTM
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/