patternMajor
Why is 2s complement of 000 equal to 111, but 9s complement of 000 is not 888?
Viewed 0 times
whyequal000but111888complementnot
Problem
I'm pretty confused so I hope I don't mix up the different terms here.
-
The two's complement representation of decimal
-
The two's complement of
-
The nine's complement of
Obviously this is totally wrong but I'm not sure which part I've misunderstood.
-
The two's complement representation of decimal
0 is simply 000-
The two's complement of
000 is 111- I imagine that complementing a number is equivalent to flipping bits in binary
-
The nine's complement of
000 is 999- This is what confuses me. Are two's complement and nine's complement similar (except for the base change obviously)?
- If they are, then I'd expect the nine's complement of
000to be888because8is the biggest digit in radix9and therefore the complement operation would assign the highest digit (8) to the lowest value input (0) [I imagine a folding from the center]
Obviously this is totally wrong but I'm not sure which part I've misunderstood.
Solution
You are very confused due what is simply poor terminology, to be honest. Both your statements 2 and 3 are false due to the same misunderstanding.
For each base $b$ there are two mainstream variants of the 'complement', the radix complement and the diminished radix complement.
The two most common bases in computer science are base $2$ and base $10$. Confusingly, the definitions usually used are:
For each base $b$ there are two mainstream variants of the 'complement', the radix complement and the diminished radix complement.
The two most common bases in computer science are base $2$ and base $10$. Confusingly, the definitions usually used are:
- one's complement: the diminished radix complement of base $2$
- two's complement: the radix complement of base $2$
- nine's complement: the diminished radix complement of base $10$ (not $9$!)
- ten's complement: the radix complement of base $10$.
Context
StackExchange Computer Science Q#135048, answer score: 32
Revisions (0)
No revisions yet.