Back to articles
Converting Fractions to Decimals and Why the Results Repeat

Converting Fractions to Decimals and Why the Results Repeat

via Dev.to BeginnersMichael Lip

Every fraction converts to a decimal, but not every decimal is finite. 1/4 is a clean 0.25. 1/3 is 0.333... repeating forever. 1/7 is 0.142857142857... with a six-digit repeating cycle. Understanding why some fractions terminate and others repeat is useful for anyone working with numerical data, precision-sensitive calculations, or even database schema design. The rule for terminating decimals A fraction in lowest terms produces a terminating decimal if and only if the denominator's prime factors are limited to 2 and 5. That is it. If the denominator factors into only 2s and 5s (the prime factors of 10), the decimal terminates. 1/4 = 1/(2^2) -- terminates: 0.25 1/8 = 1/(2^3) -- terminates: 0.125 1/20 = 1/(2^2 * 5) -- terminates: 0.05 1/25 = 1/(5^2) -- terminates: 0.04 But introduce any other prime factor and you get a repeating decimal: 1/3 -- 3 is prime, not 2 or 5: repeats 1/6 = 1/(2 * 3) -- 3 is present: repeats (0.1666...) 1/7 -- 7 is prime, not 2 or 5: repeats 1/12 = 1/(2^2 * 3) -

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
2 views

Related Articles