Fraction Calculator Website: Keep the Exact Answer

Adding 3/4 and 1/6 by adding their tops and bottoms produces the wrong result, 4/10. Use a common denominator before adding, then reduce the fraction.

A useful calculator should show why the exact answer is 11/12 rather than leave you with a rounded decimal.

This fraction calculator accepts four signed integers and one of four operations. It displays normalized operands, the selected rule, the raw fraction, its greatest common divisor and the reduced result. Changing any field clears the previous trace, and zero denominators and zero divisors are rejected before an answer appears.

Fraction Calculator Website: Keep the Exact Answer
Fraction Calculator Website: Keep the Exact Answer
Open the full example ↗

Keep the four integers separate

OpenStax distinguishes the common-denominator step for addition/subtraction from fraction multiplication and reciprocal-based division. Its division rule excludes a zero divisor. Adopt those concepts without copying exercises or artwork. OpenStax: Fraction Operations, OpenStax: Multiply and Divide Fractions

Label the first operand's numerator a and denominator b, and the second's numerator c and denominator d. The interface accepts integers with absolute value at most 10,000; both denominators must be nonzero.

Validate each whole trimmed string as an optional sign followed by digits. Blank, decimal, exponent notation, slash expression, comma-formatted number and symbolic text are invalid. Do not parse only the leading numeric fragment of 3abc or 1/2.

The calculator keeps the four entered values visible and moves a negative denominator’s sign to its numerator. For example, 1/−4 becomes −1/4. The magnitude bound is a local design limit, not a restriction on fractions in mathematics.

Select the rule before calculating

With a/b and c/d:

Selected operation Raw result
Add (ad+bc)/(bd)
Subtract (ad−bc)/(bd)
Multiply (ac)/(bd)
Divide (ad)/(bc), requiring c≠0

For addition or subtraction, bd is a valid common denominator, though it need not be the least one. Show the equivalent operands ad/bd and bc/bd. Do not describe the product denominator as the LCD in every case.

For multiplication, multiply numerators and denominators. For division, show the second operand's reciprocal and then the multiplication. Flipping the first operand changes the question; using the common-denominator addition rule for division does too.

The selected operation stays beside the answer. Switching from Add to Divide clears the previous explanation before another calculation.

Reduce without losing the sign

After the operation, normalize the result denominator positive. Use the integer greatest common divisor of the absolute numerator and denominator to reduce both. A zero numerator has the canonical result 0/1.

Original independent example Raw normalized fraction Exact reduced result
3/4 + 1/6 22/24 11/12
3/4 − 1/6 14/24 7/12
3/4 × 2/3 6/12 1/2
3/4 ÷ 2/3 9/8 9/8
1/−4 + 1/2 2/8, after sign normalization 1/4
1/2 − 1/2 0/4 0/1

The addition record includes 18/24 + 4/24 = 22/24 and gcd(22,24)=2. Subtraction gives 18/24 − 4/24 = 14/24, also reduced by 2. Multiplication reduces 6/12 by 6; division's 9/8 already has gcd 1.

The signed example begins −1/4 + 1/2, becomes −2/8 + 4/8, and reduces 2/8 to 1/4. Retain that normalization in the trace rather than silently relocating signs.

An improper result such as 9/8 remains a valid exact rational answer. This bounded helper does not add mixed-number parsing merely because one output is larger than one.

Reject zero division before creating a result

A zero denominator invalidates an operand in every mode. Dividing by a fraction with numerator zero is separately invalid, even when that operand's denominator is nonzero. For example, 3/4 ÷ 0/5 has no result in this helper.

Zero as a numerator is otherwise allowed. Multiplying 0/5 by 2/3 produces 0/1 after reduction. Do not reject all zero fields or reinterpret an empty denominator as 1.

Use the labeled fields, operation buttons and Calculate. Reset empties the fields and operation selection; choose an operation again for the next calculation.

Read the trace as a worked answer

Start with 3/4 plus 1/6 and press Calculate. The trace shows 18/24 + 4/24 = 22/24, then reduction by two to 11/12. Change the second fraction to 2/3 and select Divide: multiplying by its reciprocal gives 9/8. The operation name remains part of the trace so a new answer cannot inherit an earlier explanation.

Keep the exact rational result as the answer. This bounded calculator uses integer intermediates rather than decimal approximations. With input magnitudes at most 10,000, the largest addition numerator is 200,000,000, within JavaScript’s safe integer range. It handles one operation at a time and does not silently chain rounded results.

Copy this prompt

Create an exact two-fraction calculator with four labeled integer fields a, b, c, d representing a/b and c/d. Default to 3/4 and 1/6 with Add selected. Give Add, Subtract, Multiply and Divide buttons and a Calculate action. Accept trimmed optional signs and digits only, magnitude at most 10000. Reject blank, decimals, exponent notation, slashes and trailing text. Both denominators must be nonzero. Normalize negative denominators and retain that normalization in the trace.

Use exact integer formulas: Add (ad+bc)/(bd), Subtract (ad-bc)/(bd), Multiply ac/bd, Divide ad/bc with c nonzero. Reduce the normalized fraction by gcd; represent zero as 0/1. Show operands, operation, equivalent common-denominator fractions for addition/subtraction or reciprocal for division, raw normalized fraction, gcd and exact result. The product denominator is a common denominator, not always the least one.

Required results: 3/4+1/6=11/12; subtraction=7/12; 3/4 times 2/3=1/2; division=9/8; 1/-4+1/2=1/4. Zero numerator is valid except as the divisor’s numerator. Clear the old result on any input or operation edit; Reset empties fields and operation selection.

Return one complete HTML file. Put the four fraction fields, operation choices and exact result together, followed by the calculation steps. Use readable labels and stack the fraction inputs on a phone. Keep an invalid denominator separate from an unanswered field, and clear the previous explanation when an input changes.

Keep the operation with the result

Save the native HTML source and any calculations you want to discuss in your own math notes. Ask a partner to check the common-denominator or reciprocal step before checking the reduction. When explaining the calculation to another reader, NOS can render the prepared HTML with the exact fraction and reduction trace together. Use the 22/24 to 11/12 example to explain the reduction, then switch operations to compare the rule.

Keep reading