[Math] How to convert binary fraction to decimal

binary

I have the following binary fraction:
$$ 0.010011001100110011001100110011001100110011001100110100 $$
I want to know what number this represents in decimal. I could go like this:
$$ \frac{1}{2}\cdot0 + \frac{1}{4}\cdot1 + \frac{1}{8}\cdot0 + …$$
but this doesn't sound like the good approach. What's the algorithm? I searched the web and the algorithm is only presented for binary integers.

Best Answer

You can reverse your process for binary integers. I'm using a smaller number as an example: $0.101011_2$ Start from the least significant bit and work towards.

$(0+1)\div2=0.5$

$(0.5+1)\div2=0.75$

$(0.75+0)\div2=0.375$

$(0.375+1)\div2=0.6875$

$(0.6875+0)\div2=0.34375$

$(0.34375+1)\div2=0.671875$

EDIT: How it works: $$0.671875=\frac{43}{64}=\frac{1}{64}+\frac{1}{32}+\frac{0}{16}+\frac{1}{8}+\frac{0}{4}+\frac{1}{2}$$ $$=(((((1/2 + 1)/2 + 0)/2 + 1)/2 + 0)/2 + 1)/2$$

An aside: As your fraction is recurring you can speed up the calculation using GP techniques but I don't think that was really what you were after.

Related Question