0
$\begingroup$

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.

$\endgroup$
  • 3
    $\begingroup$ 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. $\endgroup$ – ShreevatsaR Jul 9 '11 at 9:34
2
$\begingroup$

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$.

$\endgroup$
0
$\begingroup$

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}$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.