Decimal to Fraction Converter
Fraction Converter
Enter any decimal in inches or millimeters. Returns the nearest imperial fraction in both directions — floor and ceiling — to any denominator you set. Exact matches are detected and highlighted automatically.
Quick Select
Enter a dimension to convert
How It Works
Given input value v and denominator N, the converter finds the two fractions with denominator N that bracket v — one rounding down (floor), one rounding up (ceiling).
- Unit conversion (mm only):
v_in = v_mm / 25.4. All fraction math is in inches; mm equivalents are derived. - Scale to denominator:
raw = v_in × N— expresses the input as a numerator over N. - Floor:
n_floor = floor(raw)→ value =n_floor / N - Ceiling:
n_ceil = ceil(raw)→ value =n_ceil / N - Reduction: Each fraction divided by
GCD(numerator, denominator). 4/16 displays as 1/4. - Exact match: If
|raw − round(raw)| < 1×10⁻⁹, the input is exactly representable at this denominator. The epsilon is necessary — IEEE 754 floating-point drift means0.5 × 32can compute as 16.000000000000004, not 16. - Error:
|fraction_value − v_in|, reported in the active display unit. - Closest: Whichever of floor/ceiling has smaller error. Ties go to floor.
Example — exact match: 12.7 mm, 32nds.
v_in = 12.7/25.4 = 0.5". raw = 0.5×32 = 16.
Integer → exact match: 16/32 = 1/2". Error = 0.
Example — no match: 0.356", 16ths. raw = 0.356×16 = 5.696.
Floor = 5/16 = 0.3125" (Δ 0.0435").
Ceiling = 6/16 = 3/8 = 0.375" (Δ 0.019"). Closest = 3/8".
Non-binary denominators (thirds, fifths, tenths, hundredths, thousandths) are not standard imperial callouts but are useful for decimal-inch and metric-approximation workflows.