Fraction ↔ Decimal Converter
Convert fractions to decimals and decimals to fractions. Shows simplified form, mixed numbers, and percentage.
Common Fractions
About this tool
Converting between fractions and decimals is a fundamental skill in mathematics, essential for students, professionals, and anyone working with precise calculations. Whether you're simplifying mathematical expressions, comparing numerical values, or understanding how fractions relate to their decimal equivalents, understanding both forms helps build mathematical confidence. This tool instantly converts between these two representations while showing you the simplified form, mixed number format, and even the percentage equivalent.
Simply enter a fraction like 3/4 or a decimal like 0.75, and the tool shows you the conversion in multiple formats. If you input a fraction, you'll get the decimal value along with any percentage it represents. If you enter a decimal, the tool works backwards to find the simplest fraction form, making it perfect for budgeting, cooking, engineering, or academic work where fractional measurements are common. The tool handles both proper and improper fractions seamlessly.
Frequently Asked Questions
Code Implementation
# Fraction and Decimal Conversion
from math import gcd
from fractions import Fraction
def fraction_to_decimal(numerator: int, denominator: int) -> float:
if denominator == 0:
raise ValueError("Denominator cannot be zero")
return numerator / denominator
def decimal_to_fraction(decimal: float, max_denominator: int = 10000) -> tuple[int, int]:
f = Fraction(decimal).limit_denominator(max_denominator)
return f.numerator, f.denominator
def simplify_fraction(numerator: int, denominator: int) -> tuple[int, int]:
common = gcd(abs(numerator), abs(denominator))
return numerator // common, denominator // common
def to_mixed_number(numerator: int, denominator: int) -> str:
if abs(numerator) < denominator:
return f"{numerator}/{denominator}"
whole = numerator // denominator
remainder = abs(numerator % denominator)
if remainder == 0:
return str(whole)
return f"{whole} {remainder}/{denominator}"
# Examples
print(fraction_to_decimal(3, 4)) # 0.75
print(decimal_to_fraction(0.75)) # (3, 4)
print(simplify_fraction(6, 8)) # (3, 4)
print(to_mixed_number(7, 4)) # "1 3/4"
print(f"{fraction_to_decimal(1, 3):.6f}") # 0.333333Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.