Understanding the fraction to decimal converter — concept and principle
This calculator divides a fraction out by long division and marks the repeating part in parentheses, so 1/7 appears as 0.(142857) instead of a rounded 0.142857142857. It also reports the length of the repeating block, often called the period. It is handy for homework on rational numbers, checking calculator output, and exploring number patterns.
How it is calculated
- The integer part is the whole-number quotient of a ÷ b.
- Starting from the remainder r, repeat: multiply r by 10, write down the digit ⌊10r ÷ b⌋, and keep the new remainder 10r mod b.
- Each remainder is recorded with its position. If the remainder becomes 0, the decimal terminates.
- If a remainder appears a second time, the digits written since its first appearance form the repeating block, shown in parentheses. Its length is the period.
The search stops after 200 digits, so very long periods are cut off.
The principle
When dividing by b, the remainder is always one of 0, 1, …, b − 1. After at most b − 1 non-zero remainders, one must repeat (the pigeonhole principle), and from that point the same digits come out in the same order forever. That is why every fraction gives either a terminating or a repeating decimal, and why the period is at most b − 1. The period of 1/7 reaches that maximum of 6. For a denominator with no factor 2 or 5, the period equals the smallest k for which 10^k − 1 is divisible by the denominator.
Worked example
- Inputs: numerator 1, denominator 7. Integer part 0, remainder 1.
- 10 ÷ 7 = 1 r 3; 30 ÷ 7 = 4 r 2; 20 ÷ 7 = 2 r 6.
- 60 ÷ 7 = 8 r 4; 40 ÷ 7 = 5 r 5; 50 ÷ 7 = 7 r 1.
- Remainder 1 has appeared before, so the digits 142857 repeat.
- Result: 0.(142857), repeating block length 6.
How to read the result
Digits outside the parentheses appear once; digits inside repeat without end. For example 1/6 is shown as 0.1(6): the 1 appears once and the 6 repeats. A period of 0 means the decimal terminates, which happens exactly when the reduced denominator has only the prime factors 2 and 5.
Common mistakes
- Treating a rounded calculator display such as 0.1428571429 as exact.
- Stopping long division before a remainder repeats and guessing the pattern.
- Assuming the period always equals b − 1; for 1/3 it is 1, and for 1/13 it is 6.
Frequently asked questions
Why does 1/7 give the digits 142857 and 2/7 give 285714?
Both use the same cycle of remainders, starting at a different point, so the same six digits appear rotated.
What is the longest possible period for denominator b?
At most b − 1. Primes that reach it, such as 7, 17, 19 and 23, are called full reptend primes.
How do I write repeating decimals by hand?
Common notations are a bar over the block, dots over its first and last digits, or parentheses as used here.
Sources: G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Chapter 9 (decimals and their periods)