Math & time

Exact Fraction Arithmetic: Add and Simplify Without Decimal Rounding

Calculate rational sums and products using integer numerators, denominators and greatest common divisors instead of rounded decimals.

Photorealistic editorial photo for Exact Fraction Arithmetic
Math & time · Practical ideas for your next build

A repeating decimal is an approximation of a rational value, while a fraction can represent that value exactly. For example, one third plus one sixth is exactly one half even though writing each input as a short decimal introduces rounding. Integer fraction arithmetic makes the exact relationship visible and gives a clean way to distinguish a mathematical result from a convenient decimal display.

Use a common denominator for addition

To add a/b and c/d, compute (ad + cb)/(bd). Subtraction changes the plus to minus. The product bd is a valid common denominator even when it is not the least common multiple, because the result can be reduced afterward. Normalize signs so the denominator stays positive and keep zero denominators invalid. Our calculator uses integer inputs and exact BigInt operations for these steps, avoiding a hidden decimal approximation during the calculation.

Reduce with the greatest common divisor

After computing the numerator and denominator, divide both by their greatest common divisor. This leaves the value unchanged and produces a simplified fraction. Multiplication uses ac/bd; division uses ad/bc and must reject a zero divisor. Zero results normalize to a denominator of one. Very large exact arithmetic can be expensive, so the tool bounds each input integer to fifty digits. That is a deliberate input limit, not an implication that browser memory or computation is unlimited.

Label the decimal as a separate approximation

The displayed numerator and denominator are exact integer strings. The decimal field uses ordinary floating-point conversion and may round a recurring value or a large ratio. Use the fraction fields when preserving exactness matters, and choose a rounding rule only when preparing a final decimal representation. Mixed-number and decimal input syntax are not accepted by this tool; convert them to integer fractions first. When comparing results, compare reduced rational values rather than assuming two rounded decimal strings prove equality.

Worked example

EXAMPLE
1/3 + 1/6
= (1×6 + 1×3) / (3×6)
= 9/18
= 1/2

Is the decimal result exact whenever the fraction is exact?

No. The fraction is exact, but its decimal display is a separate floating-point approximation and can round.

Reference and further reading

Read the official documentation ↗