Fraction and Decimal Calculator

Use a decimal point, such as 0.125. Exponents and repeating notation are not supported.

Exact fraction

Enter a decimal or fraction to see its exact value.

Decimal:

Maximum searches all denominators up to the limit. Specified rounds to a single requested increment.

Choose a whole number from 1 to 1,024.

Original and nearest values

Visible interval: 0 to 1.

Tick labels show position.

Original value and nearest fraction on a number lineEnter a value to place its marker.00.250.50.751

โ— Original value ยท โ—‡ Nearest fraction

Signed error = nearest fraction โˆ’ original value

Show the steps

    Enable JavaScript to calculate. Fraction and decimal guidance remains available below.

    Convert decimals and fractions, simplify exact values, and find the nearest fraction while keeping approximation error visible.

    How to use

    Choose Decimal or Fraction, then enter a value. Fraction input uses a numerator and a positive denominator, such as 3/8.

    Read the simplified exact fraction and its decimal representation. The โ‰ˆ symbol means the displayed decimal is rounded.

    To approximate the value, choose Maximum denominator or Specified denominator, enter a limit from 1 to 1,024, and select Find nearest fraction.

    Compare the original and nearest values on the number line. Fit value changes the visible interval without changing your input.

    Read the signed and absolute error before using an approximation. Copy the exact value or the labeled approximation; Reset clears the calculation.

    Science

    A finite decimal is an exact fraction whose denominator is a power of ten before simplification. For example, 0.125 is 125/1000, which reduces to 1/8. The written decimal 0.333 is 333/1000, even though 1/3 may be a convenient approximation.

    Simplifying divides numerator and denominator by their greatest common divisor without changing the value. Decimal output may still require rounding: some fractions have repeating decimal expansions.

    Maximum denominator searches for the nearest fraction among all denominators up to the chosen limit. Specified denominator instead rounds to multiples of one selected increment. These are different operations.

    Signed error is approximation minus original. A positive error lies above the original value; a negative error lies below it. Equal-distance choices favor the simpler denominator, then the value toward zero.

    An exact decimal conversion does not establish measurement accuracy. When the input came from a measurement, retain its uncertainty separately from this tool's mathematical rounding.

    Formulas

    Finite decimal as a fraction: value = signed integer digits / 10^(fractional digit count)

    Fraction simplification: n/d = (n/g)/(d/g), where g = gcd(|n|, d)

    Nearest fraction with bounded denominator: minimize |p/q โˆ’ n/d| for 1 โ‰ค q โ‰ค limit

    Signed approximation error: error = p/q โˆ’ n/d

    Relative error for a nonzero original: relative error (%) = 100 ร— |error| / |original|

    Examples

    Decimal 0.125: 1/8 exactly. 125/1000 simplifies by a common factor of 125.

    Fraction -6/8: -3/4 = -0.75. Simplification preserves the sign and exact value.

    Decimal 0.333; maximum denominator 10: 1/3; signed error 1/3000. 0.333 is 333/1000. The selected 1/3 is slightly larger.

    Decimal 0.333; specified denominator 16: 5/16 = 0.3125; signed error -41/2000. A fixed increment need not produce the same result as a maximum-denominator search.

    Decimal 0.5; maximum denominator 1: 0; signed error -1/2. Zero and one are equally far away; the declared tie rule chooses toward zero.

    References

    Python documentation: exact rational numbers and bounded denominators

    ECMAScript: BigInt integer arithmetic