|
|
from fractions import Fraction
|
|
|
|
|
|
|
|
|
def convert_feet_to_inches(value):
|
|
|
return value * 12
|
|
|
|
|
|
def convert_inches_to_feet(value):
|
|
|
return value / 12
|
|
|
|
|
|
def convert_to_meters(value, unit):
|
|
|
conversion_factors = {'Feet': 0.3048, 'Inches': 0.0254}
|
|
|
return value * conversion_factors.get(unit, 1)
|
|
|
|
|
|
def convert_meters_to_unit(value, unit):
|
|
|
conversion_factors = {'Feet': 1/0.3048, 'Inches': 1/0.0254}
|
|
|
return value * conversion_factors.get(unit, 1)
|
|
|
|
|
|
|
|
|
def decimal_to_fraction(decimal_value):
|
|
|
|
|
|
fraction = Fraction(decimal_value).limit_denominator(16)
|
|
|
|
|
|
if fraction.denominator == 1:
|
|
|
return str(fraction.numerator)
|
|
|
else:
|
|
|
|
|
|
whole_number = fraction.numerator // fraction.denominator
|
|
|
remainder_numerator = abs(fraction.numerator % fraction.denominator)
|
|
|
if remainder_numerator == 0:
|
|
|
return str(whole_number)
|
|
|
else:
|
|
|
return f"{whole_number} - {remainder_numerator}/{fraction.denominator}"
|
|
|
|