Why This Matters
Fractions are precise, but they are not always the most convenient way to express a part of a whole. Decimals extend the place value system you already know from whole numbers. Just as the digits to the left of the decimal point represent ones, tens, and hundreds, the digits to the right represent tenths, hundredths, and thousandths. The number 3.14 means 3 wholes plus 1 tenth plus 4 hundredths.
Percentages are fractions with a denominator of 100. The word "percent" literally means "per hundred." When you see 75%, think 75/100, which simplifies to 3/4, which equals 0.75 as a decimal. These three representations -- fraction, decimal, percentage -- are different ways to express the same value. Fluency means moving freely between them.
In programming, decimals are everywhere: floating-point numbers, coordinates, probabilities, and measurements. Percentages appear in progress bars, discount calculations, tax rates, and statistical analysis. Understanding how these connect to fractions prevents common errors like treating 0.1 + 0.2 as exactly 0.3 (it is not, due to floating-point representation).
Define Terms
Visual Model
The full process at a glance. Click Start tour to walk through each step.
Fractions, decimals, and percentages are three ways to express the same value. Place value extends into tenths and hundredths.
Code Example
// Fraction to decimal
const numerator = 3;
const denominator = 4;
const decimal = numerator / denominator;
console.log(decimal); // 0.75
// Decimal to percentage
const percent = decimal * 100;
console.log(percent + "%"); // 75%
// Percentage to decimal
const pct = 62.5;
const dec = pct / 100;
console.log(dec); // 0.625
// Decimal to fraction (find numerator and denominator)
function decimalToFraction(d) {
const precision = d.toString().split(".")[1]?.length || 0;
const denom = Math.pow(10, precision);
const numer = Math.round(d * denom);
// Simplify using GCD
function gcd(a, b) { return b === 0 ? a : gcd(b, a % b); }
const g = gcd(Math.abs(numer), denom);
return `${numer / g}/${denom / g}`;
}
console.log(decimalToFraction(0.75)); // "3/4"
console.log(decimalToFraction(0.125)); // "1/8"
// Floating-point gotcha!
console.log(0.1 + 0.2); // 0.30000000000000004
console.log(0.1 + 0.2 === 0.3); // false!
// Rounding to fix display
console.log((0.1 + 0.2).toFixed(2)); // "0.30"
console.log(Math.round((0.1 + 0.2) * 100) / 100); // 0.3Interactive Experiment
Try these exercises:
- Convert 5/8 to a decimal and then to a percentage. Verify all three represent the same value.
- Convert 33.3% to a fraction. What happens? Is 33.3% exactly one-third?
- Compute
0.1 + 0.2in JavaScript or Python. Why is the result not exactly 0.3? Research floating-point representation. - What percentage is 7 out of 20? Compute it as a fraction first, then convert.
- List 0.5, 1/3, 40%, and 0.45 in order from smallest to largest. Convert them all to the same format to compare.
Quick Quiz
Coding Challenge
Write a function called `convert` that takes a value and its type ('fraction', 'decimal', or 'percent') and returns all three representations as a string. For fraction input, pass a string like '3/4'. For decimal, pass a number like 0.75. For percent, pass a number like 75. Output format: 'fraction: 3/4, decimal: 0.75, percent: 75%'. Always simplify fractions. Round decimals to at most 4 decimal places.
Real-World Usage
Decimals and percentages are the language of everyday numbers:
- Financial calculations: Interest rates (4.5%), tax rates (8.25%), discounts (30% off). All financial math involves converting between these forms.
- Progress indicators: Download bars show 67% complete. This is 0.67 as a decimal, or roughly 2/3 as a fraction.
- Statistics and data science: Probabilities are decimals between 0 and 1. Confidence intervals use percentages. Data analysis lives in these conversions.
- CSS and web design: Opacity is a decimal (0.0 to 1.0). Width can be a percentage (50%). Font sizes use decimal rem values. Understanding the relationship is key.
- Scientific measurement: Lab measurements use decimals (pH 7.4, 37.5 degrees Celsius). Precision in decimal places represents measurement accuracy.