# Converting .11111 to binary w/o converting to fraction

1. Aug 27, 2014

1. The problem statement, all variables and given/known data
Imagine any recurring decimal in base 10, call it X.
examples:
.1111111111...
.2222222222....
.23232323....

my question is - can you convert it to binary without rewriting X in fractional form. I know how to do it in fractional form. I know how to convert it to fractional form as well.

However, I'm curious if one can proceed to solve this problem without converting to fractional form like a/b where a and b are integers.

2. Relevant equations
- divide/mult by 2 to convert integer/decimal part to binary

3. The attempt at a solution
The reason I ask this is because I know (and can) convert recurring decimals from binary to decimal. However, I'm not aware of any trick that does the other way around (w/o making use of fractions) and if there is one I would like to know how its done.

Thanks.

2. Aug 27, 2014

### Staff: Mentor

Hi catluvr. I'm not exactly sure what you seek, or why. But what is special about converting a recurring decimal? It won't generally be an exact equivalent, so I don't see any difference from converting any old decimal fraction into a binary fraction.

Anyway, this gives me the opportunity to pass on a technique I came up with
though I'm sure others have thought of it, too.

I'll take as an example 0.425718125(10) because I already know it has an exact binary form, I'm working backwards as a check.

You probably know about the method for converting a decimal integer into binary by repeatedly dividing by 2? Well, there's a similar technique for converting a decimal fraction into a binary fraction by repeatedly multiplying by 2, and taking note of the digit to the right of the decimal point.

EDIT I just noticed this is a homework question, so that means you are supposed to figure out the details for yourself. So I have deleted the example I provided below, to leave something you can figure out for yourself ....

< example redacted >

You can keep going until you run out of digits or your calculator overflows, then stop.

Last edited: Aug 28, 2014
3. Aug 28, 2014

I listed it as HW pretty much because I couldn't find anywhere else to put it. It isn't really a homework. It is just me being curious.

I do know how to convert integer to binary (divide by 2 and collect remainders). I also know how to convert fractional part (decimals) to binary (multiply by 2 and collect "1", and "0" in 0th place).

so to reiterate what i was saying:

I know how to convert 2/3 to binary (mult by 2 and collect "1" and "0" in 0th place)

however, the question is is there a way to convert 0.66666666666666666666666... (which is 2/3) to binary without converting it to fraction (2/3) first?

TL;DR want to convert 0.666666666666666666666.... to binary without making use of the fact that it is 2/3

4. Aug 28, 2014

### Staff: Mentor

Show me how you convert 0.66666666 to binary by a method you know.

5. Aug 28, 2014

### .Scott

When you ask "can you convert it to binary without rewriting X in fractional form", I have to assume you have ways of representing that repeating decimal and ways of working with repeating decimals in general. So this is not normal C programming, were repeating decimals are simply truncated to a limited precision.

So here is what you do:
Let R be your repeating decimal.
Store the fractional part of R into R(0).
Let n be 0.
Loop:
-- Store 2*R(n) into R.
-- Store the fractional part of R into R(n+1).
-- Store the non fractional part of R (a 0 or 1) to B(n). This will be your output.
-- Let m be 0.
-- Loop:
-- -- If m is greater than n, break from this loop.
-- -- If R(m) equals R(n+1), then:
-- -- -- You are done.
-- -- -- You have a repeating binary value from B(m) to B(n).
-- -- -- Exit this procedure.
-- -- Else
-- -- Set m to m+1.
-- End of Loop.
-- Set n to n+1.
End of Loop.

The outer loop cannot exit. If there is a repeating decimal, there will be a repeating binary. If the decimal is not repeating, it will loop forever.

6. Aug 28, 2014

### .Scott

Here's the $0.\overline{6}$ example:

$R=0.\overline{6}$
$R_{0}=R=0.\overline{6}$
$n=0$
$R=2\cdot R_{n} = 1.\overline{3}$
$R_{n+1} =$ Fractional part of $R = 0.\overline{3}$
$B_{n} =$ Non Fractional part of $R = 1$
Compare $B_{0} to B_{1}$ Not equal
$n=n+1=1$
$R=2\cdot R_{n} = 0.\overline{6}$
$R_{n+1} =$ Fractional part of $R = 0.\overline{6}$
$B_{n} =$ Non Fractional part of $R = 0$
Compare $B_{0} to B_{2}$ Equal, so we are done

Answer is in array B and values n and m:
$B_{0} = 1$
$B_{1} = 0$
$m = 0$
$n = 1$
So the overline will cross both digits of the binary value.
It will look like this: $0.\overline{10}$.

Last edited: Aug 28, 2014
7. Aug 28, 2014

0.666666666... = 2/3

2 * 2/3 = 4/3 = 1+1/3
2 * 1/3 = 2/3 = 0+2/3
2 * 2/3 = 1+ 1/3
repeat

hence 0.66666666.... = 0.101010101010101010....

now show me how to convert 0.666666.... to binary without converting it to fraction and thus making use of what i did above.

i'm also not looking for a script either.

i couldn't think of a way to do it hence why i'm curious if there is even a way.

8. Aug 28, 2014

### The Electrician

2*.6666666666666666666...
gives:
1.33333333333333333333...
the 1 becomes the first bit of the binary value which is .1xxxxxxx...--subtract the 1 and get:
.333333333333333333333...
Now 2*.33333333333333333...
gives:
0.666666666666666666666...
the zero becomes the next bit of the binary value which is now .10xxxxxx...
subtract the zero and get:
.666666666666666666666...
Now 2*.66666666666666666...
gives:
1.3333333333333333333333...
the 1 becomes the next bit of the binary value which is now .101xxxxxxx...

et cetera.

9. Aug 28, 2014

i'm not sure why i over-thought this problem so much lol. the was staring at the solution the entire time.

thanks for doing that. cheers.

10. Aug 29, 2014

### Staff: Mentor

Keep multiplying it by 2. If the digit to the right of the decimal point is 5 or greater write 1, otherwise write 0.

0.666666
1.333332
2.666664
5.333328
10.666656
21.333312
42.666624
85.333248

.10101010

You can keep this up until you calculator display overflows.

11. Aug 29, 2014

### .Scott

My method is a bit more complete because is provides a way of recognizing when you are done and what portion of the binary fraction is repeated.