tags:

views:

26

answers:

1

I read on wikipedia :
"In general, for a radix r's complement encoding, with r the base (radix) of the number system, an integer part of m digits and fractional part of n digits, then the r's complement of a number 0 ≤ N < r^(m−1)−r^(−n) is determined by the formula:

N** = (r^m − N) mod (r^m) "

I don't understand that does the number of digits i.e. m depend on the radix r ?
For ex : If I want to find 100's complement of 97 then is m=2 or m=1 ?
For m=2, I get the answer as 9903
For m=1, I get the answer as 03
So should I take m=2 or m=1 ?

A: 

The Wikipedia article on the method of complements can probably give a much better explanation than I can, but I will try nonetheless.

The number of digits does not necessarily depend on the radix, rather the context in which it is used. In other words, 5 does not have a complement in base-2 (i.e. binary), but it does have a complement in an eight-digit base-2 number -- 251. This means that in two's complement, -5 can be represented as 0b11111011.

Likewise, 97 does not have a complement in base-100. It does have a complement in a one-digit integer, a two-digit integer or an n-digit integer base-100 number.

You may choose to develop an arithmetic machine that works with 100's complement numbers. If you use one-digit integers, you could represent -3 by your 97th numeral. If you preferred two-digit integers, -3 would be represented by your 99th numeral followed by your 97th numeral.


This is a difficult concept at first, doubly so in a numeral system that hasn't been developed -- I've yet to see base-100. :-) Try flexing your method of complements muscle in smaller bases first, hexadecimal is a good start.

16's complement of 7 in a single-digit hexadecimal number is 9. In a two-digit number, it is F9. In a three-digit number, it is FF9. Hence

Sedate Alien