# decimal numbers in base ten to another base

I was wondering, is it possible to convert a floating point number such as, 3.7 into binary base? i've been thinking in polinomial descomposition but I can't transform $7x10^{-1}$ in some sume of powers of 2. Any help and book references would be greatlly appretiated.

-

Yes. For the integer part divide by 2 and note the remainders :

$\begin{array} {r|l} 3 & 1\\ 1 & 1\\ \end{array}$

For the fractional part multiply by 2 (getting $1.4$) remove the integer part and repeat :

$\begin{array} {r|l} 1.4 & 1\\ 0.8 & 0\\ 1.6 & 1\\ 1.2 & 1\\ 0.4 & 0\\ 0.8 & 0\\ 1.6 & 1\\ \end{array}$ (note the repetition with $0.8,1.6,\cdots$)

So that the answer will be :
$11.1\ \underline{0110}\ 0110\ 0110\ \cdots$
collecting the bits at the right of the tables :
- from bottom (most significant) to top (less) for the integer part and
- from top to bottom for the fractional part)

Agarwal's pdf about Number Conversions could help too.

-

When you're manually calculating the decimal for a base 10 fraction, you multiply the numerator by 10 until you have an integer greater than or equal to the denominator, and you continue this process with each step's remainder until 1) you find the decimal repeating, or 2) you reach a remainder of 0.

If you're trying to find the decimal in another base, you use the same process, except that instead of multiplying by 10, you multiply by the number base. So, to get 7/10 in binary:

1. 7 / 10 = 0 remainder 7, so you put down an optional 0, followed by a decimal. The remainder (7) multiplied by the number base (2) gives 14, the "numerator" for the next step.
2. 14 / 10 = 1 remainder 4, so the decimal is now 0.1. Remainder * base = 8.
3. 8 / 10 = 0 remainder 8, so the decimal is now 0.10. Remainder * base = 16.
4. 16 / 10 = 1 remainder 6, so the decimal is now 0.101. Remainder * base = 12.
5. 12 / 10 = 1 remainder 2, so the decimal is now 0.1011. Remainder * base = 4.
6. 4 / 10 = 0 remainder 4, so the decimal is now 0.10110. Remainder * base = 8.
7. Since 8 is the same numerator as in step 3, further steps would simply repeat steps 3-6.

So the decimal expansion for .7 in binary is 1, followed by the four-digit period 0110, which repeats indefinitely.

-

It will not terminate, but will be a repeating decimal in binary. $0.7_{10}=0.10\overline{1100}_2$ Decimals terminate in base $10$ when the denominator factors into $2^a5^b$, but in base $2$ when the denominator is a power of $2$

-
how did you get that result? is it some algorithm? – Ivan3.14 Mar 21 '12 at 22:42
I gave it to Alpha. But yes there is an algorithm. You could see en.wikipedia.org/wiki/Base_conversion#Base_conversion – Ross Millikan Mar 21 '12 at 22:43