Fraction ↔ Decimal Converter

Turn a fraction into a decimal — repeating period included — and any decimal back into an exact fraction.

How to use

  1. Pick the direction: a fraction into a decimal, or a decimal back into a fraction.
  2. For a repeating decimal, type the part that does not repeat in the first field and the digits that repeat in the second.
  3. The answer appears with the long division, or the generating-fraction algebra, written out underneath.

About this tool

Every fraction of whole numbers becomes either a decimal that stops or one that repeats forever — there is no third possibility. Which one you get depends only on the denominator once the fraction is reduced: if it is built exclusively from the primes 2 and 5, the division ends, as in 3/8 = 0.375; anything else repeats, as in 1/3 = 0.333… and 1/6 = 0.1666…. This tool runs the long division digit by digit and watches the remainders. The moment a remainder shows up for the second time, the digits from that point on are bound to repeat, and the block between the two occurrences is the period. That is how 1/7 is reported as 0.142857… with a six-digit period.

The other direction uses the generating fraction, the classic trick of subtracting two shifted copies of the same number. Call the value x. Multiplying by a power of ten large enough to move one full period past the decimal point gives a second number with exactly the same infinite tail, so subtracting the two cancels the tail completely and leaves whole numbers behind. For 0.1666… that reads 100x = 16.666… and 10x = 1.666…, so 90x = 15 and x = 15/90 = 1/6. The general form divides the difference of two digit strings by (10^m − 1) × 10^k, where m is the length of the period and k the number of digits before it. The arithmetic is done in BigInt so long decimals stay exact, and the result is then reduced by its GCD.

Converting in both directions is useful whenever a number has to change costume. Measurements written as fractions of an inch become decimals for a spreadsheet; a repeating decimal read off a calculator becomes the clean fraction that a proof or an exam answer expects. Period notation matters too, because 0.333… and 0.3 are not the same number, and writing 0.(3) removes the ambiguity. The tool accepts either the comma or the dot as the decimal mark, handles negative values, works with denominators up to 1,000,000, and does everything in JavaScript on your device — nothing you type is sent anywhere.

The formula

Fraction to decimal: long division while watching the remainders — when a remainder repeats, the digits from that point on repeat forever, and the block between the two occurrences is the period. Decimal to fraction (generating fraction): for a value with k non-repeating decimal places and a period of m digits, x = (D − P) ÷ ((10^m − 1) × 10^k), where D is every digit up to the end of the first period and P is every digit before the period. With no period, x = digits ÷ 10^k. The result is then reduced by its GCD.

Frequently asked questions

How do I know whether a fraction gives a repeating decimal?

Reduce it first, then look at the denominator: if it has any prime factor other than 2 or 5, the decimal repeats. 3/8 terminates because 8 is 2³, while 1/6 repeats because 6 contains a 3.

What is a generating fraction?

It is the exact fraction that produces a given repeating decimal. Every repeating decimal has one, which is why repeating decimals are rational numbers: 0.333… is 1/3 and 0.1666… is 1/6.

How do I enter a repeating decimal here?

Type the part that does not repeat in the decimal field and the repeating digits in the second field. Entering 0,1 with period 6 means 0.1666…, and entering 0 with period 3 means 0.333….

Is 0.999… really equal to 1?

Yes, and the tool shows why: with a period of 9, the generating fraction gives 9/9, which is exactly 1. They are two ways of writing the same number, not two numbers that are merely close.

Do my numbers leave my browser?

No. The long division and the generating fraction are both computed in JavaScript on your device, with no requests to any server.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.