# An algorithm to convert float number to binary representation

I want to know the algorithm of converting a given float (e.g, 3.14) to binary in the memory.

I read this wikipedia page, but it only mentions about the conversion the other way.

Let me quickly give the details, from the same wikipedia page:

As you know; the floating number is calculated as:

$value = (-1)^ {sign} \times 2^{exponent-127} \times fraction$

where

$exponent = 2^2 + 2^3 + 2^4 + 2^5 + 2^6$

$fraction = 1 + 2^{-2}$

in this example. Please check the wikipedia page for more detailed info.

So, we can calculate the float number with given binary but how can we do the other way algorithmically?

Thanks in advance.

-
In what way the input is given? –  dtldarek May 19 '12 at 12:59