# Thread: Given a base, find the exponent

1. ## Given a base, find the exponent

Hello people. I wanted to know if it is possible to solve this problem.

I have a range : -$\displaystyle 2^{w-1}$ to $\displaystyle 2^{w-1}-1$

so if w = 4, I would have a range -8 to 7 [-8,-7,...,0,1...,7]

This represents the range for a signed integer in 2's complement form (most computers use this format). w indicates the number of bits needed for numbers in the range specified to be represented in binary.. So if w = 4, i'll have the range [-8,7] and the binary form of 4 is 0100.

The question is, given a number, say 4, can I find out the value of w?

i.e. number = -$\displaystyle 2^{w-1}$ to $\displaystyle 2^{w-1}-1$.. find w

any help would be appreciated..

2. $\displaystyle Range = (2^{w-1}-1) - -2^{w-1}$

So if the range was 4 and you wanted to find w, then:

$\displaystyle 4 = 2^{w-1} -1 + 2^{w-1}$

$\displaystyle 4 = 2 * 2^{w-1}-1$

$\displaystyle 5 = 2 * 2^{w-1}$

$\displaystyle log{5} = log{2} + log{2^{w-1}}$

Can you continue using the law of logarithms to solve for w?