Step 7: The Subtraction Trick for Converting Repeating Decimals to Fractions

Consider the repeating decimal number:
r = 3.[14] = 3.141414...
I don't have to multiply this by an infinite power of 10. It turns out that I only need to multiply by a power of ten with the same magnitude as the length of the repeating part.

For this example the repeating sequence, [14], is n=2 digits long. So I multiply r by 10n = 102 = 100 and get
100r = 314.[14] = 314.141414...
The reason I've explicitly written equations for r and 100r, is that I want to subtract one equation from the other and make the messy repeating decimal disappear, leaving me with just an integer:
(100r - r) = 99r = 314.[14] - 3.[14] = 311
Then I solve for r.
r = 311/99
This is already reduced, since 311 and 99 are coprime, since 311=311 and 99=3*3*11.

Here's another example:
r = 0.[142857]
What is the length of the repeating part? The repeating sequence is 6 digits long, so multiply r by 106, and get
1000000r = 142857
Then subtract these two equations and solve for r.
(1000000r - r) = 999999r = 142857
r = 142857/999999
Reducing this fraction is going to take some doing. Again I am using Octave's "factor()" and "gcd()" commands to help with the heavy lifting.

It turns out that:
r = 142857/999999 = (3*3*3*11*13*37)/(3*3*3*7*11*13*37) = 1/7

So what about those occasions when there is a sequence to the right of the decimal that does not repeat, followed by a sequence that does repeat? I think that is the the most general case, and the hardest decimal-to-fraction problem to solve. For example:
r= 3.45[6]
There are couple of ways to do this one. One way is to find 1000r, 100r, and then subtract these to get 900r.
     r=  3.45[6]
1000r = 3456.[6] 
 100r =  345.[6]
 900r = 3111
    r = 3111/900 = 3*1037/3*300 = 1037/300
I do a lot of work using an <u>Integer Basic</u> that needs to work with decimal fractions +-32,000&bull;00000<br> and even double precision variables need to use some of the techniques you describe here.<br> <br> And some I did not know.&nbsp; I especially like the over-bar description of endless repeating fractions.<br> <br> A
I&nbsp;just noticed that, for some reason, a bunch of line-breaks were missing from certain parts of this instructable, so that text that used to look like:<br /> <blockquote> <div>equation1<br /> equation2<br /> equation3</div> </blockquote>wound up looking like:<blockquote> <div>equation1equation2equation3</div> </blockquote>That is to say, totally f-d up, and unreadable.&nbsp; I suspect this was the work of some Official Instructables robot going through and updating the markup language, which they change every so often for some reason. &nbsp;<br /> <br /> I think I&nbsp;fixed all the damage, but if I didn't please comment, I&nbsp;mean, in the unlikely event that someone besides me actually reads this 'ible.<br />
A handy way to remember the decimals in sevenths (mentioned in the 7th step) is 7 14 28 5.. Two times 7 is 14, two times 14 is 28, two times 28 is 56 but the repeat starts after the 5 so you only end up with 7 14 28 5..restart 7 14.. and so on. Any /7 remainder in decimals you only have to check what digit to start with - 2/7 -> 20/7 first digit will be 2. Then go from there, 0.285714285... Not that relevant to factoring, but kind of neat.
That is kind of neat ...7 14 28 5 ... Among the fractions {1/2, 1/3, 1/4, 1/5,1/6,1/7,1/8, 1/9} , 1/7 is the one with the weirdest decimal representation, and the hardest to remember... Thanks for the tip!
No prob. It's kind of a neat party trick (for very specific geekly parties) to quote percentages of stuff that there happens to be seven of. Aww man, twenty eight point five seven one four two percent of my meatballs are burned!
s/factoring/fraction to decimal/g
I noticed the proof in Step 10 had some kinda serious typos, places where "-n" that should have been "+n", and a "greater than" sign that should have been "greater than or equals". I decided these were serious enough to re-edit the picture containing this proof and upload it again. Hopefully that will be the last correction.
Hey everybody! Thank you to whoever it is who voted/decided this instructable was a winner for answering the "Decimal to Fraction" question. The subject of repeating decimals has always been interesting to me, especially repeating nines. One thing I forgot to mention in this instructable is the cultural phenomena of marketeers who offer their wares with prices ending in nines, e.g. $0.99 < $1.00 $19.99 < $20.00 The other day I found a beautiful 1.999 in the wild, and I decided to take a picture of this and add it to Step 10. BTW, if this ible has any really obvious errors, e.g. math errors, please point them out to me. Any other comments, positive or negative, are also welcome.

About This Instructable




Bio: I've built some weird stuff over the years, but most of that stuff has remained unseen by the world outside of me and a ... More »
More by Jack A Lopez:Piezo Pen Pulsed Power Source Phosphorescent Notepad Convert a bar of soap into fatty acids 
Add instructable to: