Working with fixed size integer representations, use a number system with b-complement notation, base b = 9 and n = 4 digits. What is the smallest number that can be represented in this number system? State the number in decimal, and also express it in this number system. I assume that it will be 0888 for max, and 8000 for min. If I am right, then what is the max number of integers that I can represent using this notation.
-
$\begingroup$ If you can calculate this for binary, you should be able to calculate this for any other base. $\endgroup$– Yuval FilmusCommented Oct 28, 2018 at 19:22
-
$\begingroup$ I am not sure about the first digit, whether it is always 0 for positive and n-1 (in the context of base n) for negative, or it increases until some point. $\endgroup$– Arsenij PertsovCommented Oct 28, 2018 at 20:46
-
$\begingroup$ It's up to you – arithmetic will work whatever convention you use. $\endgroup$– Yuval FilmusCommented Oct 28, 2018 at 21:30
1 Answer
As long as different 4 digit numbers in base b represent different decimal numbers, the particular notation one uses is not relevant to see how many integers can be represented. I'm not sure how the two-complement notation generalizes to the b-complement notation, but if the above property holds, then clearly there will be 9^4 representable integers.
My guess is that the first digit does not need to be 0 or 8, it can be any digit. That is, I think one could use the following encoding:
0000 0
...
4444 MAX
4445 MIN = -MAX
4446 MIN+1
...
8888 -1