0

I am aiming to show the largest representable integer with n bits in base -2 encoding. However I do not really know how to work with summations.

For example:

1001 in base -2 is -7: 1*(-2^3) + 0*(-2^2) + 0*(-2^1) + 1*(-2^0) which is -8 + 1 = -7.

As you can see the largest representable integer is the sum of -2 raised to the even exponents and 0, 2^2 + 2^0 which is 5

As another example, the smallest representable integer is the sum of -2 raised to the odd exponents, (-2^3) + (-2^1) which is -10

Is it possible to represent them through summation? If so, how?

Note:I am not really sure summation is the best way, so feel free to show other ways.

Secret
  • 149
  • 1
  • 7

1 Answers1

1

As you know, there are two cases, $n$ odd and $n$ even. It is possible to treat them together, but things are clearer if we treat them separately.

(i) $n$ odd: Let $n=2m-1$. For the largest number, we put $1$ in all the odd numbered places and $0$ elsewhere. (We could call them the even numbered places, and that's probably what I would prefer, but then we have to call the rightmost place the $0$-th place.) Working from right to left, the number we get is $$1+2^2+2^4+\cdots+2^{2m-2}.$$ It is better to write this as $$1+4+4^2+\cdots+4^{m-1}.$$ This is a geometric series with first term $1$ and common ratio $4$. The sum is equal to $$\frac{4^m-1}{4-1}.$$ We could write the sum as $$\sum_{i=0}^{m-1} 2^{2i}.$$ That does not particularly help: some people are very comfortable with summation notation, others are less comfortable. But in any case we have to find the sum of a geometric series.

(ii) $n$ even: Let $n=2m$. Then the largest number is obtained again by putting a $1$ in the rightmost place, then a $0$, then a $1$, and so on.

The sum is then again $$1+2^2+2^4+\cdots +2^{2m-2},$$ so we are finding the same sum as before, and get the same answer of $$\frac{4^m-1}{4-1}.$$

The analysis for the smallest number goes along similar lines.

Remark: It is all too easy to get the index wrong by $1$. So it is quite useful to test the correctness of the indexing by checking with small concrete values of $n$.