Fraction and Decimal Converter
Convert a decimal to the nearest simple fraction, or a fraction to a decimal and percentage.
Draft — figures checked, awaiting an editorial read. Not indexed.
Formula: Decimals convert to fractions by walking continued-fraction convergents until the error is negligible or the denominator cap is reached.
What this calculates
This converts a decimal into the nearest simple fraction, or a fraction into a decimal and a percentage. The decimal-to-fraction direction is the useful one, because it is what you need to read a calculator result onto a tape measure. A cut list that says 7.375 inches is not directly usable; 7 and 3/8 is. The denominator cap matters here — a tape measure divides to 16ths, so capping there gives you a mark you can actually find, while a machinist working to 64ths wants finer.
How it works
Converting a fraction to a decimal is straightforward division. The other direction is harder than it looks, and naive approaches get it wrong: multiplying by 1000 and reducing turns 0.333 into 333/1000 rather than 1/3. This uses continued fractions, walking the sequence of best rational approximations — 1/3, 2/5, 3/8 and so on — until the error becomes negligible or the denominator cap is reached. That produces the fraction a person would actually write, not an arithmetically equivalent but useless one.
Worked example
Converting 0.375 with a 16 denominator cap: the algorithm converges on 3/8, which is exact. A more interesting case is 0.333 — capped at 16ths it returns 1/3, since 1/3 is by far the best approximation available with a small denominator, even though 0.333 is not exactly a third. Going the other way, 1 3/4 is 1 + 0.75 = 1.75, or 175%.
Common mistakes
Setting the denominator cap higher than the tool you are using can measure. A result of 23/64 is precise and completely unhelpful if your tape only marks 16ths — round to 3/8 and move on. Second, misreading mixed numbers: "1 3/4" is one and three quarters, not one-third-of-four. Third, expecting exactness from a repeating decimal; 1/3 has no exact decimal representation, so any conversion of 0.3333 is an approximation in one direction or the other.
Common questions
- What is 0.375 as a fraction?
- 3/8 exactly. Common tape-measure decimals are worth knowing: 0.125 is 1/8, 0.25 is 1/4, 0.375 is 3/8, 0.5 is 1/2, 0.625 is 5/8, 0.75 is 3/4 and 0.875 is 7/8.
- Why cap the denominator?
- Because an unbounded conversion returns technically-correct fractions with huge denominators that no ruler can measure. Capping at 16 gives you a mark that exists on a standard tape.