# Convert number from one base to another

I have the next number: $$5.2880001*10^{-4}$$

Now I want to convert this number to a format of $X*2^y$. How I do it?

Thank you.

-
Are there any constraints on X and y? Otherwise you can always take X to be your number (0.00052880001) and y to be 0. – ShreevatsaR Jul 9 '11 at 9:34

Assuming that you want to follow a convention corresponding to the one that's used for decimal numbers (namely that X has a single non-zero digit before the decimal/binary point), you need

$$\begin{eqnarray} y&=&\lfloor\log_2s\rfloor\;,\\ X&=&2^{-y}s\;, \end{eqnarray}$$

where $s$ is your number, $\log_2$ is the base-$2$ logarithm and $\lfloor\cdot\rfloor$ is the floor function, which yields the greatest integer not greater than its argument.

If you don't have means for calculating logarithms available, you can just multiply or divide (in this case multiply) your number by $2$ until you cross $1$ to determine $y$.

-

I assume you want $1 \le X \lt 2$ and $y$ to be an integer.

You could write your expression as $0.00052880001\times 2^0$ or $0.00105760002\times 2^{-1}$ or $0.00211520004\times 2^{-2}$ and so on by doubling the left part and changing the index on the right, including $1.08298242048\times 2^{-11}$.

-