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
_____________________________________________

Complement of a Number


Date: 7/10/96 at 10:51:3
From: Anonymous
Subject: Complement of a Number

What is the formula to find the complement of a number? 
What about the binary complement?

                               -Steve


Date: 7/11/96 at 18:15:51
From: Doctor Anthony
Subject: Re: Complement of a Number

To complement a number in base 10, you subtract it from a row of 9's. 
E.g. the complement of 5097 is 4912.  Likewise, in base 2, the 
complement of a number is obtained by subtraction from a row of 1's.  
All you have to do in fact is to interchange 0's and 1's. 
E.g. the complement of 10011101011 is
                       01100010100

In binary, a convenient way of subtraction is to add the complement.  
There is a slight complication when there is a carry 1 at the extreme 
left after the addition. In this case the carry 1 is moved to the 
extreme right and added. When making up the complement it is also 
necessary to make up the second number (with leading zeros if 
necessary) to the same number of digits as the first number before 
complementing.

Example. Find 101001101    Write this    101001101 
             -011100101                 +100011010
                                        -----------
                                        1001100111

Here we have a carry 1, so remove it and add to the extreme right hand 
column.  
                                         001100111
                                                 1
                                         ----------
                                           1101000 

-Doctor Anthony,  The Math Forum
 Check out our web site!  http://mathforum.org/dr.math/   
    
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-2008 The Math Forum
http://mathforum.org/dr.math/