Decimal to Fraction Calculator

Type a decimal and this calculator returns the exact fraction it equals, reduced to lowest terms, with the greatest common divisor it cancelled shown alongside. Tell it how many trailing digits repeat and it converts recurring decimals exactly too, so 0.8333… comes back as 5/6 rather than as an approximation. For shop and workshop use it also gives the nearest fraction at any denominator from 1/2 to 1/64, the decimal that fraction really equals, and the signed error you take on by using it.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Decimal valueType the digits exactly, with an optional minus sign. Exponent notation is not accepted here.0.375
Trailing digits that repeatLeave at 0 for a decimal that stops. Enter 1 for 0.8333…, 6 for 0.142857142857…0
Nearest-fraction denominatorThe smallest division your rule, tape or drill index actually carries.Sixteenths (1/16)

It returns

  • Exact fraction in lowest terms — The precise rational value of the decimal you entered.
  • Mixed-number form
  • Greatest common divisor cancelled
  • Nearest fraction at the chosen denominator
  • Error of that approximation — Approximate value minus the exact value. Negative means the fraction is undersize.

The formula

x=NallNhead(10r1)10p
n=round(|x|D)

In plain text: Terminating: x = N / 10^p. Repeating: x = (N_all − N_head) / ((10^r − 1) · 10^p)

  • N_allEvery digit of the number, decimal point ignored, read as a whole number (integer)
  • N_headThe same with the repeating block removed from the end (integer)
  • pNon-repeating digits after the decimal point (count)
  • rDigits in the repeating block (0 if the decimal terminates) (count)
  • xThe exact rational value (—)

With r = 0 the second formula is undefined, so a terminating decimal uses x = N/10^p directly. Both results are then reduced by the greatest common divisor of numerator and denominator.

Updated Category Fractions, Decimals & Rounding Verified against published test cases Reading time 11 min

Every decimal you can write down is a fraction

A written decimal is already a fraction in disguise. The notation 0.375 means 3 tenths plus 7 hundredths plus 5 thousandths, which is 375 thousandths, which is 375/1000. Reduce that by 125 and you have 3/8. Nothing was approximated at any point — the conversion is exact, and the only real work is finding the greatest common divisor.

The same is true of decimals that never stop, provided they eventually repeat. A repeating decimal is a geometric series, and geometric series with a ratio below 1 sum to a rational number. That is the precise sense in which 0.333… is one third rather than being close to it. What cannot be written as a fraction is a decimal whose digits never terminate and never fall into a repeating block — √2 and π are the standard examples, and any decimal you can actually finish typing is by definition not one of those.

This matters in practice because fractions are exact and decimals often are not. A machinist reading a print in decimal inches, a woodworker translating a cut list, and a student asked for an answer in simplest form all need the same operation: recover the fraction the decimal came from, and know how much a convenient shop fraction would cost them if they used it instead.

How the conversion works, terminating and repeating

Terminating decimals are the easy case. Count the digits after the point — call it p — then write every digit of the number as a whole number over 10p. For 0.375, p = 3, so the fraction is 375/1000. For 2.5, p = 1, giving 25/10. Reduce by the greatest common divisor and you are done: 375/1000 cancels by 125 to 3/8, and 25/10 cancels by 5 to 5/2.

Repeating decimals need one extra idea. Suppose the last r digits repeat forever and p digits sit between the point and the start of that block. Multiplying by 10p+r and by 10p produces two numbers with identical infinite tails, so subtracting them cancels the tail exactly and leaves a whole number. Written out, that gives

x = (Nall − Nhead) / ((10r − 1) × 10p)

where Nall is every digit read as an integer and Nhead is the same with the repeating block chopped off the end. The familiar shortcuts fall straight out of it: with p = 0 the denominator becomes 10r − 1, which is why 0.3̄ = 3/9 = 1/3, 0.7̄2̄ = 72/99 = 8/11, and 0.142857 repeating = 142857/999999 = 1/7.

The 9s-and-0s pattern people memorise — one 9 per repeating digit, one 0 per non-repeating digit — is exactly (10r − 1) × 10p. Knowing where it comes from means you never have to guess how many of each to write.

Worked example: 0.8333… to an exact fraction

Take a decimal read off a calculator as 0.8333, where you know the 3 continues forever. Enter it with one repeating digit and follow the arithmetic.

  1. Split the digits. After the point there are four digits, 8333. The last r = 1 of them repeats, so p = 4 − 1 = 3 non-repeating digits, namely 833.
  2. Build Nall. Every digit of the number as a whole number: 0 followed by 8333 is 8333.
  3. Build Nhead. The same with the repeating block removed: 0 followed by 833 is 833.
  4. Subtract. 8333 − 833 = 7500. This is the numerator.
  5. Build the denominator. (101 − 1) × 103 = 9 × 1000 = 9000.
  6. Reduce. gcd(7500, 9000) = 1500, since 7500 = 1500 × 5 and 9000 = 1500 × 6. So 7500/9000 = 5/6.
  7. Check. 5 ÷ 6 = 0.833333…, which is what you started with.

Now the shop approximation at sixteenths. Multiply the exact value by 16: 0.833333 × 16 = 13.3333, which rounds to 13, so the nearest sixteenth is 13/16. That fraction is 0.8125 exactly, so the error is 0.8125 − 0.833333 = −0.020833 — about 21 thousandths undersize. On a woodworking joint that is invisible; on a bearing fit it is a scrapped part. Going to sixty-fourths instead gives 53/64 = 0.828125, still 5.2 thousandths under. This value simply does not sit near a binary fraction, which is the useful thing the error column tells you.

Reading the result: exact fractions versus shop fractions

The two fractions this calculator gives you answer different questions. The exact fraction is what the decimal equals, full stop; use it in algebra, in unit conversions, and whenever a marking scheme asks for simplest form. The nearest shop fraction is what you can actually set on a rule, a tape or a drill index, and it is right only to within the error shown.

Whether the two coincide is decided by the reduced denominator. A fraction can be written exactly in halves, quarters, eighths, sixteenths, thirty-seconds or sixty-fourths only when its reduced denominator is a power of two that divides your chosen denominator. So 0.375 = 3/8 lands exactly on a sixteenths rule, 0.6875 = 11/16 lands exactly, and 0.8333… = 5/6 never will at any binary denominator, because 6 contains a factor of 3.

Use the error column rather than intuition about how fine a division looks. Rounding to the nearest sixty-fourth guarantees an error of at most half of 1/64, which is 1/128 or 0.0078 in — under 8 thousandths. The nearest sixteenth guarantees at most 1/32, or 0.031 in. Those bounds are the honest limits of working in fractions at all; if your tolerance is tighter than the bound, you need to work in decimals and measure with an instrument that reads them.

For the reverse trip — a fraction you want as a decimal, with the repeating block marked — use the fraction to decimal calculator. If the fraction you get back is improper and you want it as a whole number plus a remainder, the mixed number to improper fraction calculator converts in both directions, and the simplifying fractions calculator shows the Euclidean algorithm behind the reduction step in full.

Inch fraction, decimal and millimetre reference

Sixteenths of an inch with their exact decimal and millimetre equivalents. One inch is defined as exactly 25.4 mm, so every millimetre figure here is exact.
FractionDecimal (in)Millimetres
1/160.06251.5875
1/80.1253.175
3/160.18754.7625
1/40.256.35
5/160.31257.9375
3/80.3759.525
7/160.437511.1125
1/20.512.7
9/160.562514.2875
5/80.62515.875
11/160.687517.4625
3/40.7519.05
13/160.812520.6375
7/80.87522.225
15/160.937523.8125
11.025.4

Every decimal here terminates because 16 = 2⁴, and a denominator built only from 2s and 5s always terminates in base ten. Halve any row to get the thirty-seconds, and halve again for the sixty-fourths.

How to tell whether a decimal repeats before you convert it

Reduce the fraction you expect and look at the denominator's prime factors. Only 2s and 5s means the decimal terminates; any other prime means it repeats, and the length of the repeating block is the multiplicative order of 10 modulo that part of the denominator. This is why sevenths always repeat in blocks of six digits (1/7 = 0.142857…) and why thirds and sixths repeat in blocks of one.

Going the other way, if you have read a decimal off a display you often cannot tell whether it terminated or was truncated. A calculator showing 0.8333333 could be 5/6 or could be 8333333/10000000. Only you know which, which is why the repeating-digit count is something you tell this calculator rather than something it guesses.

Mistakes and limits worth knowing

  • Treating a truncated display as a terminating decimal. Entering 0.3333 with zero repeating digits gives 3333/10000, not 1/3. Set the repeating count to match what the number really does.
  • Miscounting the non-repeating digits. In 0.8333… the block is one digit long and three digits precede it. Getting p wrong changes the denominator by a factor of ten.
  • Rounding before converting. Convert from the fullest decimal you have. Rounding 0.6874 to 0.687 first turns an 11/16 fit into a mess.
  • Assuming any denominator can be hit exactly. Thirds, sixths, sevenths and elevenths never land on a binary rule. The error column, not the denominator you chose, tells you whether the approximation is usable.
  • Ignoring the sign of the error. A negative error means the fraction is undersize, which is the safe direction on an outside dimension and the unsafe one on a hole. The direction, not just the magnitude, decides which way you can afford to be wrong.
  • Entering more than about fifteen digits. Browsers hold whole numbers exactly only to fifteen or sixteen digits, so a very long decimal can produce a fraction whose last digits are off. The calculator warns you when you cross that line.
  • Confusing a decimal inch with a decimal foot. 2.5 ft is 2 ft 6 in, not 2 ft 5 in. Convert the unit first, then the fraction.

Where this sits among the alternatives

The method here is exact conversion: it recovers the unique fraction whose decimal expansion is what you typed. A different and equally legitimate question is which simple fraction is closest to a decimal, allowing a denominator you did not specify — the answer to that comes from continued fractions, which is how 355/113 emerges as the famous approximation to π, correct to seven digits with a three-digit denominator. This calculator deliberately does not do that: for a value read off a print, the fraction that produced it is what you want, not the prettiest nearby one.

The shop-fraction half of the tool is the practical counterpart. Binary subdivisions of the inch exist because halving is the one operation you can do accurately with a folded rule or a pair of dividers, which is why rules carry 1/2, 1/4, 1/8, 1/16, 1/32 and 1/64 rather than tenths. Machinist references such as Machinery's Handbook print exactly this chart in sixty-fourths for the same reason. Metric work sidesteps the whole question by subdividing decimally, and since 1959 the inch has been defined as exactly 25.4 mm, so conversions between the two systems are themselves exact rather than approximate.

If your decimal came out of a measurement rather than a drawing, decide how many of its digits you actually trust before converting — the significant figures calculator makes that judgement explicit, and the rounding calculator lets you cut the value to a place you can defend before you turn it into a fraction.

Frequently asked questions

What is 0.375 as a fraction?

Exactly 3/8. There are three digits after the decimal point, so the raw fraction is 375/1000, and the greatest common divisor of 375 and 1000 is 125. Dividing both by 125 gives 3/8, which is also exactly 6/16, so it lands precisely on a sixteenths rule with no error at all. As a percentage it is 37.5%.

How do I convert a repeating decimal like 0.666… to a fraction?

Enter the digits you can see and tell the calculator how many of them repeat — for 0.666… type 0.6 with one repeating digit, or 0.666 with three; both give 2/3. By hand, the shortcut is one 9 in the denominator for each repeating digit and one 0 for each non-repeating digit after the point. So 0.6̄ = 6/9 = 2/3, 0.1̄2̄ = 12/99 = 4/33, and 0.16̄ = (16 − 1)/90 = 15/90 = 1/6.

Which decimals cannot be written as a fraction?

Only those whose digits never terminate and never settle into a repeating block — the irrational numbers, such as √2, π and e. Any decimal you can finish writing down, and any decimal with a repeating pattern however long, is rational and has an exact fraction. The repeating block can be very long: 1/97 repeats with a period of 96 digits, but it does repeat, so it is rational.

How accurate is rounding to the nearest 1/16 or 1/64?

Rounding to the nearest sixteenth puts you within half of 1/16, which is 1/32 or 0.03125 in. The nearest sixty-fourth puts you within 1/128, or 0.0078125 in — under eight thousandths. Those are worst-case bounds; the actual error for your value is shown directly, with its sign, so you can see whether the fraction is over or undersize rather than guessing.

Why does the calculator ask how many digits repeat instead of working it out?

Because the digits alone cannot tell it. The entry 0.8333 might be the exact terminating value 8333/10000, or it might be a display truncation of 5/6. Both readings are consistent with what you typed, and they are different numbers. Only you know which one your source meant, so the repeating count is an input rather than a guess.

What is the difference between the exact fraction and the mixed number?

They are the same value in two notations. The exact fraction 5/2 and the mixed number 2 1/2 are equal; the improper form is easier to compute with, and the mixed form is easier to read and to set on a rule. For values below 1 the two outputs are identical, because there is no whole part to split off.

Can I convert a negative decimal?

Yes — type the minus sign and it carries through to the numerator, which is the standard way to write a negative fraction. The nearest shop fraction is found from the magnitude and then given the same sign, and the error keeps its sign too, so a negative error still means the approximation sits below your exact value on the number line.

Why does 25.4 appear in the millimetre column?

Because the international yard and pound agreement of 1959 defines the inch as exactly 25.4 millimetres. That is a definition rather than a measurement, so every millimetre figure in the reference table is exact, not rounded: 1/16 in is exactly 1.5875 mm. It also means inch-to-millimetre conversion never limits the precision of a result — only your measurement does.

References