Complement of a NumberDate: 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/ Date: 06/19/2008 at 14:44:07 From: Bob Subject: 55778: Complement of a Number I was searching for terminology regarding what the term for the original number is. The complement is the "complement" but what do you call the number you started with (i.e. the complement's complement)? I came across your answer for the complement of a number being the number subtracted from a series of 9's. I believe this is actually the diminished complement which is equal to the complement less one, so the complement of 9 is 1, 8 is 2, etc. and the complement of 0.25 is 0.75. I think generally the complement of x is thought of as b^n - x, where n is an integer such that base^n >= x >= base^(n-1). Just wanted to bring this to your attention to review. Thanks. Date: 06/22/2008 at 23:15:57 From: Doctor Peterson Subject: Re: 55778: Complement of a Number Hi, Bob. Dr. Anthony evidently assumed that "complement" meant "nines complement" or "ones complement", which you are calling "diminished [radix] complement". I don't think it's a good idea to use the word "complement" without any modifier at all, unless the context makes it very clear (e.g. in the C programming language the word is used of the "~" operator to mean the ones complement). To clarify this, the archived answer could be modified by adding something like this at the start: You have not said what kind of complements you are asking about, but I will assume you mean the "tens complement" in base 10 and the "ones complement" in base 2. In my experience, it is the tens (radix) complement that is used for subtraction, though as Dr. Anthony showed, it can be done. So with this one addition to prevent people from misinterpreting it, it's probably good enough. Note that this is one of our earlier answers; there are others that go into more depth on different kinds of complements. - Doctor Peterson, The Math Forum Check out our web site! http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/