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?
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.
n
's complement use: (simple three step method).
Suppose 512 - 96 = ?
(both numbers are given in base n, say base:14).
Find n-1
complement of 96
(second number which is to be subtracted).
13
's complement of 099
is DDD - 096 = D47
(since A=10, B=11, C=12, D=13).
Find n
's complement by adding 1
to n - 1
's complement value. 14
's complement is D47 + 1 = D48
.
Add the first number (512
) with the n
's complement (D48
) and leave the carry. 512 + D48 = 45A
(carry 1
removed).
CHECK:
512(14 base) = 996(10 base)
96(14 base) = 132(10 base)
996-132 = 864(base 10) = 45A(base 14) HENCE CHECKED.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With