How to stop AI getting numbers wrong

A chat assistant will explain a VAT rule well and still get the 147th invoice wrong. The fix is how you split the work, not a better prompt.

Short answer

Do not let the language model do the arithmetic. Send the numbers to something deterministic — a spreadsheet formula, a script or a calculation engine — and use the model only to pick the rule and explain the result. The same inputs then always give the same output, and every figure can be re-run and checked.

Why do AI chatbots get maths wrong?

A language model writes an answer one token at a time, choosing what is most likely to come next. A number in its answer is produced the same way as a word: as likely-looking characters, not as the result of a calculation. Numbers are also split into tokens in chunks that do not line up with place value, which is part of why long multiplications and long columns of figures go wrong.

Current models are far better at arithmetic than they were, and some assistants quietly run code for calculations. But you usually cannot see whether a figure was computed or predicted, and the answer is not guaranteed to be the same twice. For office work, "usually right" is not a standard: one wrong figure in a batch of 200 costs more time to find than the batch took to produce.

The mistakes that actually happen

  • Percentage direction. Taking VAT out of a gross amount of 125 at 25% gives a net of 125 / 1.25 = 100. Taking 25% off gives 125 × 0.75 = 93.75. Both look plausible; only one is right.
  • Rounding. Rounding VAT per line and rounding it on the invoice total give different totals. So do round-half-up and round-half-to-even. A model will pick one without telling you.
  • Long sums. Adding 60 amounts, or multiplying two six-digit numbers, is where predicted digits drift.
  • Silent omissions. A row is skipped, or a figure from an earlier message is reused, and the total still looks reasonable.
  • Units and currencies. Hours against days, gross against net, euros against dollars.

The fix: split the work between a calculator and the model

Models are good at language: understanding what you asked, choosing which rule applies, and explaining an outcome in plain words. Calculators are good at arithmetic. Give each the part it is good at.

StepWho does itWhy
Understand the request, pick the ruleModelLanguage task
Evaluate the formulaDeterministic engineSame inputs, same output, every time
Round to your policyEngine, explicitlyRounding is a rule, not a style choice
Explain the result, flag anything oddModelLanguage task, working from the engine's figures
Approve, send or fileA personAccountability stays with people

How to set it up, step by step

  1. Write each rule as a formula with named inputs. For example net = gross / 1.25 and vat = gross - net. Put the rounding in the formula: round(x * 100) / 100 rounds to cents.
  2. Keep formulas in one place, with a version. Not copied between spreadsheets, where they drift apart.
  3. Evaluate with a deterministic engine and record the inputs, outputs, formula version and time for each run.
  4. Give the model the result and ask it to explain — not to check or recompute it. Tell it so in the instructions.
  5. Spot-check by re-running. The same inputs must give byte-identical outputs. If they do not, something other than the engine is doing arithmetic.
  6. Keep a person on the decision. The engine and the model prepare; someone approves.

How OpenClerq does it

OpenClerq has a calculation engine written in Rust that runs on your machine. You send it a formula, or a set of formulas with named inputs, and it returns the values with a proof record: a calculation id, a timestamp, the operation, a proof hash and the engine version.

POST /calculate/eval
{
  "spec": {
    "formulas": { "net": "gross / 1.25", "vat": "gross - net" },
    "output_names": ["net", "vat"]
  },
  "inputs": { "gross": 125 }
}

→ {
    "values": { "net": 100, "vat": 25 },
    "proof": { "calculation_id": "…", "timestamp": "…",
               "proof_hash": "…", "is_audit_ready": true, … }
  }

In the desktop app's Ask panel, simple requests such as "add 25% to 100" or "calculate a * b where a=12 b=30" are recognised and sent to the engine first. The model receives the engine's result as context and explains it. OpenClerq's default system prompt tells the model never to present a number as its own calculation and not to recalculate figures it is given.

Limits today

The natural-language detector covers simple patterns: percentages, plain expressions and named variables. Anything more involved should be written as a formula spec — which is what you want for recurring work anyway. The engine supports the usual operators, min, max, round, floor, ceil, powers, roots and logarithms; the full list is in the arithmetic API reference.

What about spreadsheets?

A spreadsheet formula is deterministic too, and if your team has clean, well-kept spreadsheets, keep them. Use AI to explain the results, draft the covering note, or spot a figure that looks out of line — not to produce the figures.

Spreadsheets go wrong in other ways: formulas copied between files drift, a range misses the new rows, and there is no record of which version of the formula produced last month's number. A single formula store with a proof record for each run fixes those. Either approach beats asking a chatbot to add up a column.

Frequently asked questions

Can ChatGPT do accurate calculations?

Often, for simple sums — especially when it runs code in the background. It is not guaranteed, the same question can give a different answer, and you cannot always tell whether a figure was computed or predicted. For figures that go on invoices, payslips or filings, use a deterministic calculator and let the model explain the result.

Why does AI get percentages wrong?

Usually the direction. Removing 25% VAT from a gross amount means dividing by 1.25; taking 25% off means multiplying by 0.75. They give different answers, and an ambiguous prompt lets the model choose. Writing the rule as a formula removes the ambiguity.

Does setting the temperature to zero make AI arithmetic reliable?

It reduces variation between runs but does not turn text prediction into calculation, and providers do not promise identical output even at zero. Treat it as a way to make explanations more consistent, not as a way to make figures correct.

Does OpenClerq send my figures to an AI provider?

The calculation engine runs locally. The model sees what you ask it to explain, including the engine's result. Use a local model through Ollama or LM Studio and nothing leaves your machine; with a cloud provider, the context preview shows exactly what would be sent before anything is.

Try OpenClerq on your own machine

Free and MIT-licensed. Installers for macOS and Windows start the gateway and calculation engine for you; bring a local model or your own API key.

Download installers View source