Talk:Method of complements
From Wikipedia, the free encyclopedia
I never really heard about Ten's complement, Nine's complement etc. until today, so I am probably not the one to tidy up this article. I found a decent brief explanation of them for anyone else who wants to try. Someone who's better at math, please give it a look. -- Wapcaplet 01:50, 7 Nov 2003 (UTC)
Part of the Nine's Complement section wasn't correct, so I posted a little note of what seems to be the solution. . . --Joeedh 08:56, 15 Sep 2004 (UTC)
- Thanks, though usually comments such as this (notes to other contributors) should not be visible in the article; to make such comments invisible in the article, yet visible in the edit window, you can surround them with HTML comment tags:
<!-- ... -->
. I'm having trouble understanding what you mean by this comment, though. You mention that 873-100 does not give a correct answer (did you mean 773?): 100 complemented is 899; 873 + 899 = 1772; drop the initial "1", giving 772; add 1, giving the correct answer 773. If you meant that subtracting a number smaller than 100 produces a wrong answer, I don't think that's true either; for example, for 873-50, complement 50 = 949; 873 + 949 = 1822; drop the "1" = 822; add 1 to get 823, the correct answer. The first digit in the intermediate result will always be "1" (unless x < y, which is a special case discussed in the next section) so I see no difference between subtracting 1 from it, or removing it altogether - and it should always be dropped. -- Wapcaplet 18:27, 15 Sep 2004 (UTC)
- Must have been an error in my code implementation. I'm using it for a infinite-precision integer library for a C++ class. Thanks for the tip.
Contents |
[edit] Nine's vs. nines'
I don't think "nines' complement" is correct. The system works by finding the complement of each digit with respect to a value of nine, and there need not be multiple nines involved. The nine's complement of 3, for instance, is 6. It works similarly to two's complement, which works by finding each digit's complement with respect to the value 2. If there are no objections within a few days, I will revert. -- Wapcaplet 18:11, 18 Nov 2004 (UTC)
- I strongly agree. But I notice that nothing has happened since November of last year. Do you want to do this or shall I? Rick Norwood 19:21, 12 September 2005 (UTC)
-
- I think the text in the last paragraph of the Numeric Complements section is accurate. But I wrote it, so please correct it if not. I've only seen the topic addressed in one place, Knuth's The Art of Computer Programming (volume 2, section 4.1). See also Talk:Signed number representations. Logical as his argument seems to me, if another author has a different opinion, I'll consider it. Of course, language is what writers use, and a lot of them use nine's, whether Knuth agrees with it or not! --Rick Sidwell 01:49, 13 September 2005 (UTC)
- Knuth is a man with strong opinions, some of them correct. Rick Norwood 14:32, 13 September 2005 (UTC)
Yeah, I guess it makes sense to follow the normal rules of English grammar. Complement with 9 == nine's complement, complement with multiple 9s == nines' complement. -- Wapcaplet 03:04, 14 September 2005 (UTC)
It's an interesting issue. The most common use is to put the apostrophe before the 's', and I noted that in the paragraph about the issue. But it isn't really an important part of the overall topic, so I removed the references to it elsewhere in the article. (Besides, to me "Knuth's apostrophe convention" describes his method of `quoting' in TeX, not his preference for naming radix complements.) --Rick Sidwell 14:59, 24 September 2005 (UTC)
[edit] Computers don't use two's complement for subtraction!
I removed the following statement:
- One practical application of the method of complements is for performing subtraction in a computer microprocessor which uses the binary numeral system. Binary computers typically employ the two's complement for the operation of subtraction.
Computers do use two's complement for representing numbers; it makes addition and subtraction of signed integers a lot easier. But they don't subtract by complementing and adding as described in this article; they subtract using subtraction circuitry. --Rick Sidwell 03:20, 8 Jun 2005 (UTC)
~~ @Rick Sidwell "they subtract using subtraction circuitry" ~~ A subtraction is performed by inverting the B inputs (making one's complement) before they reach the adder. In the adder the carry will add 1 (in effect turning the one's complement into two's complement for free. Thank you, carry). If there's was a borrow the carry would have been cleared at an earlier stage, in which case the addition of 1 would have been omitted. Neat, isn't it? :-) Maybe modern processors have added circuitry that's dedicated to subtraction, I don't know, but this is the way it was always done. SvenPB 14:14, 15 August 2005 (UTC)
- Makes sense. I've been meaning to rework this article for awhile, and included this in the new version. Please correct it if I got it wrong! It certainly still needs some work; I'd like to include a discussion of how mechanical calculators like the Pascaline and Curta made use of the method of complements. --Rick Sidwell 02:09, 18 August 2005 (UTC)
[edit] Deletion
I removed the following incorrect text:
- The n's complement of m is n - m. For example, the ten's complement of 7 is 3; the one's complement of 1/3 is 2/3, the hundred's complement of 28 is 72.
It's true that the ten's complement of 7 is 3, and if you consider "28" a single digit in base 100, I suppose it's hundred's complement is "72". But the ten's complement of 28 is also 72, not -62, and the ten's complement of 007 is 993. And ones complement (no matter where you put the apostrophe) only makes sense in base 2; the example would be something like the ones' complement of 01/11 is 10/11, which may look like 1/3 and 2/3 converted to binary until you add more digits and get 0001/0011 and 1110/0011. --Rick Sidwell 00:41, 14 September 2005 (UTC)
-
- What is going on here is that the same word, "complement", is used in two very different contexts, computer science and elementary education. I'll move the way the word is used in elementary education to the proper section. Maybe we should split the article, and expand the education section with more examples of how complements are being used to teach subtraction. Rick Norwood 12:28, 14 September 2005 (UTC)
[edit] Borrowing complex
How exactly is borrowing any more complex than carrying (which you have to do in this method)? Plugwash
- I can only say that schoolchildren find it so, especially when you have to borrow from a number several columns to the left. Apparently computers also find carrying easier than borrowing. Rick Norwood 20:49, 24 September 2005 (UTC)
-
- I think i've realised why humans find borrowing tricky, its because adding two single digit numbers to produce a small two digit number is drummed into thier heads. whereas subtracting two single digit numbers in the same way isn't (negative numbers are normally done as sign-magnitute and aren't taught until later).
-
- As for computers they do it that way because it allows them to have one set of cuircitry for addition and subtraction and it probablly seemed saner to do subtraction by additions and complements than addition by subtraction and complements. Plugwash 21:21, 24 September 2005 (UTC)
- I would like some sources to back up the statement schoolchildren find it so. It's not that I don't believe it, but it would be good to have a justification. 171.16.2.2 13:41, 28 October 2005 (UTC)
-
- Sources would be nice, although I personally don't know where to look for them. But to answer the original question, borrowing is more complex than carrying in several ways. With carrying, you generate the carry after adding the digits in one column and immediately use it by adding it to the next column. With borrowing, you borrow before subtracting, and the common practice is to cross out the digit and write one less above it, with the special consideration when the digit is zero to write nine and repeat the borrowing process. A simpler way would be to just mark that 1 was borrowed and deal with it when subtracting that column and marking a borrow from the next column if it is needed (including the case when the digit is zero). That's how an electronic "full subtracter" would work, but it isn't very intuitive for a human doing a manual subtraction. --Rick Sidwell 21:56, 29 October 2005 (UTC)
[edit] End around carry in nines compliment
The article says "Fortunately, a trick can be used to get around this addition: Instead of always setting a carry into the least significant digit when subtracting, the carry out of the most significant digit is used as the carry input into the least significant digit (an operation called an end-around carry). So if y ≤ x, the carry from the most significant digit that would normally be ignored is added, producing the correct result. And if not, the 1 is not added and the result is one less than the radix complement of the answer, or the diminished radix complement, which does not require an addition to obtain."
I wish the author of this section could provide a numerical example. I am trying see this and how it works on pencil and paper, but somehow I am missing the method. Thanks. 192.80.95.242 (talk) 14:48, 12 June 2008 (UTC) —Preceding unsigned comment added by 192.80.95.242 (talk) 14:45, 12 June 2008 (UTC)