Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
3  
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

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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