How to find N's complement of a number?
I want to find 9's complement of number but failed.
I tried it with the methods of 1's and 2's compl开发者_运维百科ements 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-1complement of96(second number which is to be subtracted).13's complement of099isDDD - 096 = D47(since A=10, B=11, C=12, D=13).Find
n's complement by adding1ton - 1's complement value.14's complement isD47 + 1 = D48.Add the first number (
512) with then's complement (D48) and leave the carry.512 + D48 = 45A(carry1removed).
CHECK:
512(14 base) = 996(10 base)
96(14 base) = 132(10 base)
996-132 = 864(base 10) = 45A(base 14) HENCE CHECKED.
加载中,请稍侯......
精彩评论