views:

470

answers:

1

Hi all,

I want to find 9's complement of number but failed.

I tried it with the methods of 1's and 2's complements but no effect.

What is common method to find out the N's complement of a number?

+3  A: 

The nines' complement in base 10 is found by subtracting each digit from 9.

So 45 (= ...000045) becomes 54 (= ...999954).

Ten's complement is just nines' complement plus 1. So ...000045 becomes (...999954 + 1) = ...999955.

More info on Wikipedia.

Mark Byers
Thats fine ..but ,what is the 53's complement of 200(binary) --- (51)(53)(53)--what is this?
Renjith G
How can 200 be binary? Binary has only 0 and 1 digits.
Mark Byers
sorry , i mean its decimal...200(decimal)
Renjith G
@Renjith: 200 decimal in base 53 is: (3)(41), so the 52s' complement is (49)(11) and the 53's complement is one more, i.e. (49)(12).
Mark Byers
Note there are only two radix complements in any base: the radix complement and the diminished radix complement. To ask for the 53's complement in base 10 is a meaningless question.
Mark Byers
@ Mark : can you please explain little bit clearly?
Renjith G
@Renjith: In base n, there are only two complements: ns' complement and (n-1)'s complement. So in decimal there are only two meaningful things you can ask for: 9s' complement or 10's complement.
Mark Byers
@Renjith: Binary has only 1's-complement and 2's-complement; base-10 has only 9's-complement and 10's-complement. "53's-complement" only makes sense if you are working in base-53 or base-54 (the two cases have different meanings and will give different answers). As far as I'm aware, complements are only used in computing, so the only ones that are really important in the real-world are the two complements used in binary (and occasionally the decimal-complements, if you're writing code that uses BCD numbers http://en.wikipedia.org/wiki/Binary-coded_decimal)
BlueRaja - Danny Pflughoeft
Thanks. But Can you explain the real use of 1's and 2's complements in real computing, with one example?/renjithg
Renjith G
@Renjith: An actual usage of this is to represent negative numbers. For example -1 can be represented by ...11110 if using the 1s' complement system. and .....11111 with 2's complement. Most modern systems use 2's complement. See http://en.wikipedia.org/wiki/Signed_number_representations for more info.
Mark Byers