Decimal to Fraction
Tape-measure math: round a decimal inches value to the nearest 1/8, 1/16, 1/32, or 1/64.
Example
You enter
- Value (in) 2.375
- Round to 16
You get
- Whole (in) 2
- Numerator 3
- Reduced denominator 8
- Decimal value (in) 2.375
- Rounding error 0
Details, formula, and sources
Reduce the fraction to lowest terms, break it into feet-inches, and report the rounding error (first-principles arithmetic).
ticks = round(value * den); whole = floor(ticks/den); fraction = (ticks - whole*den)/den reduced by GCD; feet = floor(whole/12); error = rounded - exact.
Decimal-to-fraction tape-measure math - nearest 1/N rounding, GCD reduction, and feet-inch decomposition; first-principles arithmetic, public domain.
Pure arithmetic, public; binary (power-of-two) denominators are the tape-measure / machinist-scale standard.
Estimate. AHJ and licensed professional govern.
Field names used by the API: value_in, denominator, whole_in, numerator, reduced_denominator, decimal_value_in, error_in
- Binary denominators rounds to a power-of-two tape-measure fraction (2/4/8/16/32/64)tape-measure / machinist scale convention