curatedapi
Browse the docs

Guides

Finance

Excel functions

Late payments

E-invoices

Accounting

Number checks

VAT and GST

Billing and pricing

Money and currencies

Dates and time

Math

Unit conversion

Everyday

Health

Fraction arithmetic API

Add, subtract, multiply, divide and simplify fractions and mixed numbers, with the exact repeating decimal.

POST https://api.curatedapi.com/v1/calc/math/fraction

Works with exact fractions such as 3/4, mixed numbers such as 1 1/2, and decimals. Results are always in lowest terms and include the mixed number, a rounded decimal and the exact decimal expansion with its repeating block in parentheses (1/6 = 0.1(6)).

Formula

a/b + c/d = (ad + bc)/bd, then reduced by the greatest common divisor

Inputs

Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).

InputTypeDescription
operation required simplify | add | subtract | multiply | divide What to do. Options: simplify: reduce a to lowest terms; add: a + b; subtract: a − b; multiply: a × b; divide: a ÷ b
a required string First fraction, e.g. '3/4', '-1 1/2' or '0.75'. At most 200 characters.
b string Second fraction (not used by simplify). At most 200 characters.
options.rounding half_even | half_up | half_down | up | down | ceiling | floor Rounding mode applied once to each result. Default half_even.
options.decimals integer Round results to this many digits after the decimal point.
options.significant_digits integer Round results to this many significant digits.

Result

Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.

ResultTypeDescription
fractionstringResult in lowest terms, e.g. '1/2' or '3'.
numeratorstringNumerator in lowest terms (a string, since it can exceed JavaScript's safe integer range).
denominatorstringDenominator in lowest terms (always positive).
mixed_numberstringResult as a mixed number, e.g. '1 1/2'.
decimaldecimal (string)Result as a rounded decimal.
repeating_decimalstringExact decimal with the repeating block in parentheses.
is_terminatingbooleanTrue when the decimal expansion ends.

Examples

1/3 + 1/6

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/fraction \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "add",
    "a": "1/3",
    "b": "1/6"
  }'
200 OKResponse
{
  "calculator": "math/fraction@1",
  "result": {
    "fraction": "1/2",
    "numerator": "1",
    "denominator": "2",
    "mixed_number": "1/2",
    "decimal": "0.5",
    "repeating_decimal": "0.5",
    "is_terminating": true
  },
  "exactness": {
    "decimal": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 20
  },
  "inputs": {
    "operation": "add",
    "a": "1/3",
    "b": "1/6"
  },
  "formula": "a/b + c/d = (ad + bc)/bd, then reduced by the greatest common divisor",
  "references": [
    {
      "title": "Fraction (mathematics)",
      "url": "https://en.wikipedia.org/wiki/Fraction"
    },
    {
      "title": "Repeating decimal",
      "url": "https://en.wikipedia.org/wiki/Repeating_decimal"
    }
  ],
  "warnings": []
}

Mixed numbers

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/fraction \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "multiply",
    "a": "1 1/2",
    "b": "2/3"
  }'
200 OKResponse
{
  "calculator": "math/fraction@1",
  "result": {
    "fraction": "1",
    "numerator": "1",
    "denominator": "1",
    "mixed_number": "1",
    "decimal": "1",
    "repeating_decimal": "1",
    "is_terminating": true
  },
  "exactness": {
    "decimal": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 20
  },
  "inputs": {
    "operation": "multiply",
    "a": "1 1/2",
    "b": "2/3"
  },
  "formula": "a/b + c/d = (ad + bc)/bd, then reduced by the greatest common divisor",
  "references": [
    {
      "title": "Fraction (mathematics)",
      "url": "https://en.wikipedia.org/wiki/Fraction"
    },
    {
      "title": "Repeating decimal",
      "url": "https://en.wikipedia.org/wiki/Repeating_decimal"
    }
  ],
  "warnings": []
}

Repeating decimal

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/fraction \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "simplify",
    "a": "22/7"
  }'
200 OKResponse
{
  "calculator": "math/fraction@1",
  "result": {
    "fraction": "22/7",
    "numerator": "22",
    "denominator": "7",
    "mixed_number": "3 1/7",
    "decimal": "3.1428571428571428571",
    "repeating_decimal": "3.(142857)",
    "is_terminating": false
  },
  "exactness": {
    "decimal": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 20
  },
  "inputs": {
    "operation": "simplify",
    "a": "22/7"
  },
  "formula": "a/b + c/d = (ad + bc)/bd, then reduced by the greatest common divisor",
  "references": [
    {
      "title": "Fraction (mathematics)",
      "url": "https://en.wikipedia.org/wiki/Fraction"
    },
    {
      "title": "Repeating decimal",
      "url": "https://en.wikipedia.org/wiki/Repeating_decimal"
    }
  ],
  "warnings": []
}

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.