# How to convert a decimal to a fraction easily?

Given a decimal like $1.5$, I want to find an easy way to write it as $3/2$ in this case is easy but given a decimal such as $0.3760683761$, how could I figure out it can be written as $572/1521$? Thx.

Edit

In case anyone is interested in more about this, I found the following links (more could exist, but what I have is enough - Thx to your contributions):

• What about $3760683761/10000000000$ ? Commented Aug 20, 2015 at 22:48
• I wouldn't say it's easy, but you can always write a terminating decimal as the fraction $\frac{3760683761}{10000000000}$ by multiplying $\frac{0.3760683761}{1}$ by $\frac{10^{10}}{10^{10}}$ and reduce. Commented Aug 20, 2015 at 22:48
• If you want the exact value, it is just $3760683761/10000000000$. If you want to find a good approximate value with a smaller denominator, look up "continued fractions". Commented Aug 20, 2015 at 22:48
• "and reduce" - would you be able to do the Euclidean algorithm quickly in a pinch? Commented Aug 20, 2015 at 22:50
• For repeating decimals, you can use geometric series to write as a fraction. Commented Aug 20, 2015 at 22:54

Here's a different way to proceed, using as little as possible of the theory of continued fractions. First write $$\frac01 < 0.3760683761 < \frac11$$ so right away we have a pair of fractions that approximate 0.3760683761. They are not very good approximations though!

Now if we have $\frac ab$ on the left and $\frac cd$ on the right, we should check $\frac{a+c}{b+d}$ to see where it lies. In this case $\frac ab = \frac01$ and $\frac cd = \frac 11$ so $\frac{a+c}{b+d} = \frac{0+1}{1+1} = \frac12 = 0.5$:

$$\frac01 < 0.3760683761 < \frac12< \frac 11$$

so forget about $\frac11$, which is too big. Now repeat: Next is $\frac{0+1}{1+2} = \frac13$, which is too small:

$$\frac01< \frac13 < 0.3760683761 < \frac12$$

Next is $\frac{1+1}{2+3} = \frac25$, which is too big:

$$\frac13 < 0.3760683761 < \frac25 < \frac12$$

Next is $\frac{1+2}{3+5} = \frac38 = 0.375$, which is an excellent approximation:

$$\frac13 < \frac38 < 0.3760683761 < \frac25$$

Unfortunately for this example, there is no better approximation than $\frac38$ until we get to $\frac{44}{117}$. usually the convergence is quicker, but this happens to be an unusually badly-behaved example, and so takes several more steps:

$$\frac13 < \frac38 < \frac{44}{117} < 0.3760683761< \frac{41}{109} < \cdots < \frac{17}{45} < \frac{14}{37} < \frac{11}{29} < \frac8{21} < \frac 5{13} < \frac25 < \frac12$$

But it does find $\frac{44}{117} \approx .37606837606837606837$, which is extremely close, and perhaps is what you were looking for. On the other hand perhaps $\frac 38$ was close enough and you could stop there.

If you want $0.3760683761$ exactly, you can continue the process, which will eventually terminate with exactly $\frac{3760683761}{10000000000}$.

One pleasant feature of this algorithm is that it always produces fractions in lowest terms, so you never have to worry about reducing them afterwards.

The theory of continued fractions provides a way to perform this calculation much more quickly, producing the continued fractional result $$0.3760683761 \approx \cfrac1{2+\cfrac 1{1+\cfrac1{1+\cfrac1{1+\cfrac1{14}}}}}$$

• Thx for the detailed explanation. The method you have suggested is interesting and I may take the time to try to turn it to a small program. I need to brush a bit on the "Continuted Fractions" as well. Commented Aug 21, 2015 at 21:59

First note that $.\overline{376068}\cdot (1000000-1)=376068$. It follows that $$.\overline{376068}=\frac{376068}{999999}=\frac{572}{1521}.$$ Edit with more details.

In your example you have a repeating decimal $.\overline{376068}=.376068376068376068...$

Let $x=.\overline{376068}$. If we multiply by $1000000$ we get $$1000000x=376068.376068376068...$$ If we now subtract $x$ we have $$1000000x-x=376068.\overline{376068} -0.\overline{376068}=376068.$$ It follows that $(1000000-1)x=376068$ and $x=\frac{376068}{999999}$. Reducing this fraction gives the result you are looking for.

In general, if you have a terminating decimal you can multiply and divide by an appropriate power of ten (i.e. $1.5=1.5\cdot\frac{10}{10}=\frac{15}{10}=\frac{3}{2}$). In the case of a repeating decimal, you can generalize the technique that I used above. Note that I used $10^6=1000000$ in the solution as the repeating part of the decimal is six digits long. If you have a non-terminating non-repeating decimal then you cannot write it as a fraction.

Hope that helps!

• Some details may help me understand your answer. Commented Aug 20, 2015 at 23:01
• In practice reducing these fractions involves factoring 'repunits'. A google search will result in large tables of factored repunits.
– Eric
Commented Aug 20, 2015 at 23:23
• Just one point here...Reducing $\frac{376068}{999999}$ produces $\frac{125356}{333333}$ which I don't see how to get $\frac{572}{1521}$ from it. However, your method does what I asked for in general - Thx for the detailed explanation. Commented Aug 21, 2015 at 22:13
• The trick for reducing the resulting fraction is to use known factors of 'repunits'. See en.wikipedia.org/wiki/Repunit#Factorization_of_decimal_repunits. If we know that $999999=9\cdot 111111=3^3\cdot7\cdot11\cdot13\cdot37$ then we can attempt to divide the appropriate factors from the denominator. You will find that $376068=44\cdot3\cdot7\cdot11\cdot37$
– Eric
Commented Aug 22, 2015 at 0:03
• Using the repunit factorization we can reduce this fraction to $\frac{44}{3^2\cdot 13}=\frac{44}{117}$ which is the reduced form of $\frac{572}{1521}$. In practice, knowing the factors of the denominator makes reducing a fraction manageable as there are only a few prime divisors to attempt to reduce by.
– Eric
Commented Aug 22, 2015 at 0:14

Note that any terminating decimal form can be written by multiplying the number by a power of $10$ until you get an integer, and then dividing by a power of $10$ until you get the original number.

In that sense, $1.5=\frac{15}{10}$ and the problem becomes factoring those two numbers. In this case we end up with $\frac{3\cdot5}{2\cdot5}$ which simplifies to the result.

Thus, for your example, the problem is really just finding the prime factorization of $3760683761$ and, since the denominator will be powers of $10=2\cdot5$, you can cancel out all powers of $2$ and $5$ that you can, and the result is further irreducible.

• I guess the keyword here is "prime factorization" - Also, the concept of Continued Fractions suggested by @David at his comment is a good idea. I wounder if there is an "Algorithm" to involve the two approaches? Thx Commented Aug 20, 2015 at 23:00
• There are obviously no 2s nor 5s in the prime factorization of 3760683761.
– MJD
Commented Aug 20, 2015 at 23:24
• good point there is clearly no way to reduce the fraction. and @EmmadKareem no there is no algorithm. this is the exact reason why it is so hard to find large prime numbers. trial division (just testing factors) is easiest for smaller numbers but quickly gets difficult Commented Aug 20, 2015 at 23:47

The difficulty with this question -- and it is one that has come up in the comments to several answers, but has not yet been explicitly addressed by any of the answers -- is that it appears that the number you are actually interested in is not the number you think you are interested in.

Here is a (completely hypothetical, made-up) scenario that I suspect is not too far off the mark from what is going on here. You are trying to solve some kind of problem; maybe it's "find the zeroes of such-and-such polynomial". Using a graphing calculator or some other form of computer algebra system, you graph the polynomial and then use the technology's built-in numerical tools to find the location of the zero. The calculator tells you the answer is $0.3760683761$. But the correct solution, according to the textbook, is $572/1521$. You confirm, by entering this into your calculator, that the results are equal, and want to know how you could have found the fraction yourself.

But here's the thing: those results are not equal. $572/1521$ is not $0.3760683761$. It is only approximately that. As Eric pointed out in his answer, $572/1521$ is actually equal to $0.376068~376068~376068 \dots$, with a repeating block of six digits. If you round this to fit on a calculator display, the result will look like $0.3760683761$. But that is misleading you: That truncation cannot be converted into the form $572/1521$, because it isn't equal to $572/1521$.

So the real question ought to have three parts to it:

• If I see a decimal output that appears to terminate, how can I know if it is really just a truncated form of a repeating decimal with a long block of repeating digits?
• If the "true" decimal value is actually repeating, how do I convert it to a fraction?
• If the "true" decimal value is actually terminating, how do I convert it to a fraction?

For the second part of the question, see Eric's answer on how to express a repeating decimal as a fraction.

For the third part of the question, see Elliot G's answer on how to express a terminating decimal as a fraction.

The real problem is the first part. How do you know if the decimal you see is actually the decimal you want? The answer, unfortunately, is that if you are relying on some form of technology to produce your solution, there is no way to know. Calculators are fundamentally finitary devices that work with numerical approximations. A calculator can't understand the actual value of $1/3$, it can only understand $0.333333333$ to a finite number of places. And if you see $0.333333333$ on a calculator screen, you can't really know if it is supposed to be $1/3$, or $333333333/1000000000$, or if maybe there are some other completely different digits hiding off the screen, buried deep in the decimal expansion.

More precisely, there is no way to tell from a finite string of digits whether you are looking at a part of a terminating decimal, a part of a repeating decimal, or a part of an irrational number. There is just no way. This leads to some (quite absurd) misconceptions, as for example in this page from a book for kids which blithely asserts that $8/23$ is an irrational number because its decimal expansion just goes "on and on" with no apparent pattern.

The moral of the story is, if you are expected (in a certain classroom context, which I assume is the case here) to solve a certain problem and get an answer like $572/1521$, the odds are good that you are supposed to solve it using some method that leads directly to that solution, rather than obtain an approximate numerical value using some technology and then try to reverse-engineer from it the correct value.

• Thank you for the detailed answer. I see your point and is good. In my case, I am solving an algebra problem that has a lot of numbers. I don't like displaying the numbers in decimal format because this makes the calculation steps look more complex than necessary and a bit un-natural when I present the solution and its details to others. Commented Aug 21, 2015 at 21:49
• That kids' book is horrifying. Just for the record, it appears to concern $8/23$, not $18/23$. Commented Dec 5, 2017 at 21:22
• @LSpice Thanks for catching that typo! Fixed. Commented Dec 5, 2017 at 22:38

Assuming you aren't concerned with non-terminating decimals (numbers where the decimal portion never ends, like $0.5555555...$), you can always put a terminating decimal number into the form of a fraction by setting the denominator as 10^(number of digits in the decimal portion), then setting the numerator as the decimal multiplied by the denominator.

For example, $1.55$ has $2$ digits in its decimal portion ($55$), so the fraction form has denominator $10^2 = 100$, and numerator $1.55 \cdot (denominator) = 155$. Thus, its fraction form is $155/100$.

The problem with "reducing" your answer is that you have to find factors for both the numerator and denominator. Once you know what your factors are, then the rest of the process is pretty self-explanatory. Unfortunately, finding factors is not a simple task. There are no known functions that can solve general cases "easily": https://en.wikipedia.org/wiki/Integer_factorization

There are, however, tricks that can ease the task of brute forcing your way through finding factors: http://www.mathsisfun.com/divisibility-rules.html Also, you never have to check for factors past the square root of an integer (e.g. if I verified that all numbers up to 12 don't divide 127, then 127 must be prime). Practice these techniques, and you will eventually gain the intuition so that you won't have to "think" about the process of turning a decimal into a fraction.

• And of course, even in some cases of non-terminating decimals you can simplify in this way. See proofs that 0.99999... = 1 etc
– sjb
Commented Aug 21, 2015 at 15:34

Just do 1 ÷ your decimal (example: 0.135) and take that number, and and do the following: 1÷0.135=7.4074074 therefore if 0.135=0.135/1 then that is equal to 1/7.4074074 and now just multiply by multiples of ten (to both the numerator and the denominator) to get your fraction. Then it's a simple matter of reducing that fraction.

• But $\frac{1}{0.135} \neq 7.4074074$; instead $\frac{1}{0.135} \neq 7.\overline{407}$. Commented Aug 21, 2015 at 10:39

The theory of primes is that any number can be written as a product of prime factors, so 572/1521 can be written as 2*2*11*13 / 3*3*13*13 which reduces down to 44/117.

The theory of decimals is that any decimal number can be written as a product and ratio using three whole numbers, e.g. xxx.xxxx = A * B/C.

• I do not think you have sufficiently addressed the original quesion Commented Aug 21, 2015 at 3:37