0
$\begingroup$

There's an algorithm to convert binary integer into decimal integer that is based on the expanded form of a number: $$ 12 = 2\cdot(2\cdot(2\cdot(2\cdot 0 + 1)+1)+0)+0 $$

\begin{aligned} & 2\cdot0+1=1\\ & 2\cdot1+1=3\\ & 2\cdot3+0=6\\ & 2\cdot6+0=12\\ \end{aligned}

I'm wondering if there's any similar algorithm to convert binary fraction to decimal fraction? Maybe also based on the expanded form: $$x_{1}\cdot 2^{-1}+x_{2}\cdot 2^{-2}+x_{3}\cdot 2^{-3} = 0.625$$

$\endgroup$
2
  • $\begingroup$ Some time happen! Thanks for sharing! Have a nice day! And try to post such problems on stackoverflow.com. $\endgroup$ Commented Jul 21, 2016 at 7:17
  • 3
    $\begingroup$ @MithleshUpadhyay What? Why? It falls within the scope of Math.SE. $\endgroup$ Commented Jul 21, 2016 at 7:19

1 Answer 1

3
$\begingroup$

Yes, you can do that.

Note that this is not often how it's done in practice, because it depends on doing most of the arithmetic on base-ten representations, which is awkward and slow on most computer architectures.

Instead one might, for example, start by multiplying by an appropriate power of ten (corresponding to how many decimals after the point you want), then remove the fractional part and convert the integer part to base ten by a standard algorithm. Afterwards put the decimal point back in.

$\endgroup$
1
  • $\begingroup$ thanks, can you please provide a simple example? $\endgroup$ Commented Jul 21, 2016 at 8:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.