Exact calculator

Evaluate an arithmetic expression exactly, with no floating-point error, and return the result as a decimal string.

CHF 0.001 / callCall itTry it
Thomas arithmometer, ca. 1820
Thomas arithmometerca. 1820

Details

Supports: + - * / ^, parentheses, 7% (= 0.07), variables, and sqrt, cbrt, root, abs, floor, ceil, round, round_even, round_to, trunc, min, max, sum, avg, mod, ln, log10, log2, log, exp, pow, percent, pi, e.

Exact: + - * / and integer powers are exact fractions (0.1 + 0.2 = 0.3). sqrt, ln, exp and non-integer powers are computed to 50+ digits and marked exact: false.

Rounding: decimals, significant digits, or round_to a step such as 0.05 (Swiss cash rounding), with 7 rounding modes.

Price: CHF 0.001 per call (first 100 calls per day free).

Example: {"expression":"0.1 + 0.2"} → {"value":"0.3","exact":true}.

Call it

REST
curl -X POST https://api.tausendwerk.xyz/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{"expression":"0.1 + 0.2"}'
MCP tool name
calculate

After the free 100 calls per day, add a key: Authorization: Bearer tw_live_…. Pricing

Try it

Runs against the live API with the free allowance.

Input schema JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "expression"
  ],
  "properties": {
    "expression": {
      "type": "string",
      "minLength": 1,
      "maxLength": 5000
    },
    "variables": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "number"
        ],
        "description": "A number. Send a string such as \"0.1\" to keep it exact."
      },
      "description": "Named values, e.g. {\"price\": \"19.90\", \"qty\": 3}"
    },
    "decimals": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Round the result to this many decimal places."
    },
    "significant": {
      "type": "integer",
      "minimum": 1,
      "maximum": 60,
      "default": 30,
      "description": "Significant digits for non-terminating results. Default 30."
    },
    "round_to": {
      "type": "string",
      "pattern": "^\\d*\\.?\\d+$",
      "description": "Round to a multiple of this step, e.g. \"0.05\" for Swiss cash rounding."
    },
    "rounding": {
      "type": "string",
      "enum": [
        "half_up",
        "half_even",
        "half_down",
        "up",
        "down",
        "toward_zero",
        "away_from_zero"
      ],
      "description": "Rounding mode for decimals and round_to. Default half_up."
    }
  },
  "examples": [
    {
      "expression": "0.1 + 0.2"
    },
    {
      "expression": "price * qty * (1 + vat)",
      "variables": {
        "price": "19.90",
        "qty": 3,
        "vat": "0.081"
      },
      "round_to": "0.05"
    }
  ]
}

More in Exact maths and money