Dear Uncle Colin,

How would you write $\frac{1}{10}$ in binary?

Binary Is Totally Stupid

Hi, BITS, and thanks for your message!

I have two ways to deal with this: the standard, long-division sort of method, and a much nicer geometric series approach.

Long division-esque

While I can do the long division method, I can’t easily typeset it. So I’m going to tackle it by the double-and-remainder method.

Let $x = \frac{1}{10}$.

Then I find:

  • $2x = \frac{1}{5}$
  • $4x = \frac{2}{5}$
  • $8x = \frac{4}{5}$
  • $16x = 1 + \frac{3}{5}$
  • $32x = 3 + \frac{1}{5}$

Now, I know what 3 is in binary - it’s $11_2$. If you’ll forgive me mixing decimal and binary representations, I know that that $2^5 x = 11_2 + 2x$.

Dividing both sides by $2^5$ gives $x = 0.00011_2 + 2^{-4} x$, which gives the recursive result $x = 0.0001100110011…_2$.

Geometric series

It’s always been a source of delight for me that, in base 10, $0.\dot{9} = 1$ exactly. This is a result that can be shown using the sum of a geometric sequence: $S =\frac{a}{1-r}$, where $a$ is the first term and $r$ is the common ratio (as long as it’s between -1 and 1). (In that example, $0.\dot{9} = \frac{9}{10} + \frac{9}{100} + \dots$; we have $a = \frac{9}{10}$, $r =\frac{1}{10}$ and the result follows.)

Now, can we engineer a similar result for $\frac{1}{10}$ using “nice” binary numbers? Let’s have a think. We want $\frac{a}{1-r} = \frac{1}{10}$, or $10a = 1-r$, where $a$ and $r$ are numbers easy to express in binary.

One possibility is $r = -\frac{1}{4}$ and $a = \frac{1}{8}$, but this would give me a bit of a headache with negative numbers.

Suppose $a$ and $r$ have the same denominator, $2^k$, and numerators $A$ and $R$. Then we can rewrite our target expression as $10A = 2^k - R$ - we’re looking for a “nice” multiple of 10 that’s a nice distance away from a power of 2. For example, with $k=5$, we get $A=3$ and $R=2$ - which gives us $a = \frac{3}{32}$ and $r = \frac{1}{16}$.

A geometric series with first term $\frac{3}{32}$ and common ratio $\frac{1}{16}$ would look like: $0.0001100110011…_2$, as we had before!

Hope that helps,

- Uncle Colin