# Given a base, find the exponent

• September 3rd 2010, 04:35 PM
widgaga
Given a base, find the exponent
Hello people. I wanted to know if it is possible to solve this problem.

I have a range : - $2^{w-1}$ to $2^{w-1}-1$
• September 4th 2010, 02:09 AM
tonio
Quote:

Originally Posted by widgaga
Hello people. I wanted to know if it is possible to solve this problem.

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

I don't get it: what's the question, anyway?

Tonio
• September 4th 2010, 06:52 PM
Educated
Widgaga has double posted his question, one with more detail than the other. The actual question is:

Quote:

Originally Posted by widgaga
Hello people. I wanted to know if it is possible to solve this problem.

I have a range : - $2^{w-1}$ to $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 = - $2^{w-1}$ to $2^{w-1}-1$.. find w

any help would be appreciated..

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

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

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

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

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

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

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