Search code examples
architecturenumbershardwaremipsdigits

n complement of a number in hardware


Do you know an algorithm or a way to find out the complement of a number in base N.?

      For example number 001112 which is in base 3 .

Thank you


Solution

  • For a number with k digits, subtract it from (Nk)N (perform the subtraction in base N, of course).