Skip to tool
ecech.
📊 Math & Statistics

0.3333333 Should Become 1/3, Not 3333333/10000000

Putting the digits over a power of ten is exact and useless. Continued fractions find the simplest fraction that is close enough — the same method that gives 355/113 for π.

Simplest fraction

Exact fraction

digits over a power of ten

Error

Mixed number

Percentage

Better and better approximations

Nearest measuring fraction

Advertisement

How the calculation works

Approximating 3.14159, one step at a time 3/1 3.000000 off by 0.14 22/7 3.142857 off by 0.0013 333/106 3.141509 off by 0.000081 355/113 3.141593 off by 0.0000029 Each step is the best fraction possible for its size of denominator.

How to Use This Tool

Type a decimal and you get the simplest fraction that matches it within your tolerance, plus the exact conversion so you can see the difference.

Why not just put the digits over a power of ten?

Because it answers the wrong question. 0.3333333 over ten million cancels to 3,333,333/10,000,000, which is perfectly exact and completely useless — the number was obviously meant to be a third, and the exact answer hides that.

The method used here is continued fractions: take the whole part, invert the remainder, repeat. Each round produces a fraction that is the best possible for its size of denominator, and you stop when the denominator gets bigger than you allowed.

Working through 3.14159, the ladder is 3/1, then 22/7, then 333/106, then 355/113. That last one is accurate to 2.9 millionths and is the best approximation of π you can write with a denominator under 16,000 — it drops out of the algorithm without being a special case.

Choose the denominator limit to match the job

  • 16 or 64 for anything you will measure or cut. A tape measure has sixteenths; machinist rules go to sixty-fourths. A fraction you cannot find on the tool is not useful however accurate it is.
  • 1,000 for general arithmetic, where you want something recognisable.
  • 1,000,000 when you want the closest fraction and do not care how it looks.
The fraction is exact. The decimal is not. 1/10 exactly one tenth 0.1 as a double 0.10000000000000000555 0.1 + 0.2 0.30000000000000004441 Binary has no exact tenth, just as decimal has no exact third.
This is why money is stored in whole cents rather than as decimal fractions.

0.1 is not 0.1

Computers store decimals in binary, and binary has no exact tenth — the same way decimal has no exact third. The closest double to 0.1 is 0.10000000000000000555, and adding 0.1 to 0.2 gives 0.30000000000000004441 rather than 0.3.

So the fraction 1/10 is exact and the decimal your computer holds is not, which is the opposite of the intuition most people have. It is also why financial systems store money as whole cents rather than as decimal fractions of a currency unit.

This tool works from the digits you typed rather than the stored value, so those artefacts do not leak into the answer.

Repeating decimals

If the digits you typed go on forever, tick the box. 0.333… with the 3 repeating is exactly 1/3; 0.1666… with the 6 repeating is exactly 1/6; 0.142857 repeating is exactly 1/7.

The algebra is a nine-based trick: a single repeating digit goes over 9, two over 99, three over 999, and non-repeating digits at the front shift everything by a power of ten. That is why 1/7 has a six-digit repeat — 999999 divides by 7 and no shorter run of nines does.

Advertisement

Frequently Asked Questions

How do you convert a decimal to a fraction?
Two ways. Putting the digits over a power of ten and cancelling is exact but usually unhelpful — 0.3333333 becomes 3333333/10000000. Continued fractions instead find the simplest fraction within a tolerance, which gives 1/3, and that is almost always what was meant.
What is 0.375 as a fraction?
Exactly 3/8. It is one of the decimals that converts cleanly, because its denominator is a power of two — the same reason it can also be stored exactly in binary floating point.
Why is 355/113 used for pi?
Because it is the best rational approximation of π with a denominator under about 16,000, accurate to 2.9 millionths. It is not a special case: run the continued fraction algorithm on π and it appears on its own after 3/1, 22/7 and 333/106.
Why does 0.1 + 0.2 not equal 0.3?
Because binary has no exact tenth, just as decimal has no exact third. The closest double to 0.1 is 0.10000000000000000555, so the sum comes to 0.30000000000000004441. The fraction 1/10 is exact; the decimal the computer holds is not.
How do I convert a repeating decimal to a fraction?
A single repeating digit goes over 9, two over 99, three over 999, and any non-repeating digits at the front shift everything by a power of ten. So 0.333… is 1/3 and 0.142857 repeating is 1/7 — 999999 divides by 7, which is why the repeat is six digits long.
What fraction should I use for measuring?
Set the denominator limit to 16 or 64, depending on your tool. A fraction that is more accurate but does not appear on your tape measure or rule is not useful — nearest sixteenth is the practical answer for most work.

Related tools in Math & Statistics

Browse all Math & Statistics tools
A handwritten note reading ecech.com resting on the keyboard used to build the site.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.