<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk" -->

---
title: Don't let the LLM do the math | daily.dev
description: When building AI-powered products that output numbers users act on, LLMs should never handle arithmetic, pricing lookups, or rankings. A hybrid architecture...
canonical: https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Don't let the LLM do the math | daily.dev
og:description: When building AI-powered products that output numbers users act on, LLMs should never handle arithmetic, pricing lookups, or rankings. A hybrid architecture...
og:url: https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk
og:image: https://api.daily.dev/og/posts/lCKz0DPQK.png
og:image:alt: Don't let the LLM do the math
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Don't let the LLM do the math

**[Flavio Copes](https://daily.dev/sources/flaviocopes)** · 4 min read · 2 upvotes · 1 comments

## Summary

When building AI-powered products that output numbers users act on, LLMs should never handle arithmetic, pricing lookups, or rankings. A hybrid architecture separates concerns: curated pricing data in SQLite, deterministic cost computation in TypeScript (integer cents, no floating point), and the LLM restricted to writing prose rationale only. This approach makes the engine fully testable with fixtures, enables graceful degradation when the LLM is unavailable, and ensures users see trustworthy numbers computed in code rather than hallucinated by a model. The LLM receives pre-computed results and is explicitly instructed not to alter any figures — and even if it does, the UI renders from the engine's JSON output, not the model's text.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://flaviocopes.com/dont-let-the-llm-do-the-math>

## Questions this post answers

### why shouldn't I let an LLM calculate prices or costs in my product

Language models are unreliable at arithmetic because they optimize for plausible text, not ledger math, so they drift, round incorrectly, forget tier boundaries, and often produce outdated pricing figures. A hybrid architecture keeps a deterministic cost model in code (integer cents, no floating-point errors) and restricts the LLM to writing explanatory prose from pre-computed numbers.

_daily.dev surfaces engineering approaches like this for developers designing trustworthy AI-powered pricing features._

### how can I make my AI product still work when the LLM API is unavailable

Design the core engine to function independently of the language model by making the LLM adapter return null when no API key is configured, so reports still generate, stacks still rank, and costs still compute, with only the LLM-written rationale section omitted. This graceful degradation treats the LLM as an optional presentation layer, not a dependency.

_developers building resilient AI features can track patterns like this via daily.dev for handling model outages gracefully._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Let the model write the explanation. Keep it far away from the invoice total, just in case.

## Similar posts on daily.dev

- [Hybrid AI: Combining Deterministic Analytics with LLM Reasoning](https://daily.dev/posts/hybrid-ai-combining-deterministic-analytics-with-llm-reasoning-gtx99tbc2) · Towards Data Science · 2 upvotes · 0 comments
- [Stop Being an AI Babysitter: How to Use LLMs Without Losing Code Ownership](https://daily.dev/posts/stop-being-an-ai-babysitter-how-to-use-llms-without-losing-code-ownership-1cbod061k) · Sergio Lema · 31 upvotes · 4 comments
- [How LLMs Can Be Assisted To Do Arithmetic Correctly](https://daily.dev/posts/how-llms-can-be-assisted-to-do-arithmetic-correctly-04arkfsu0) · Hackaday · 1 upvotes · 0 comments
- [Optimizing Cost per Insight in AI Data Analytics Systems](https://daily.dev/posts/optimizing-cost-per-insight-in-ai-data-analytics-systems-9skawywiz) · SitePoint · 0 upvotes · 0 comments
- [Stop generating, start thinking](https://daily.dev/posts/stop-generating-start-thinking-7jjvm8uwh) · Hacker News · 16 upvotes · 1 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#typescript](https://daily.dev/tags/typescript), [#sqlite](https://daily.dev/tags/sqlite)

[View this post on daily.dev](https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Don't let the LLM do the math","url":"https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk"},"datePublished":"2026-07-20T08:24:04.274Z","dateModified":"2026-09-14T08:20:29.747Z","description":"When building AI-powered products that output numbers users act on, LLMs should never handle arithmetic, pricing lookups, or rankings. A hybrid architecture...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/907c6c028f107fad7d0379f1571dde35?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/907c6c028f107fad7d0379f1571dde35?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Flavio Copes","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Flavio Copes","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/1f2dbd275797411bbd37bfdaaf0951a9","url":"https://daily.dev/sources/flaviocopes"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"llm,typescript,sqlite","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Flavio Copes","item":"https://daily.dev/sources/flaviocopes"},{"@type":"ListItem","position":3,"name":"Don't let the LLM do the math"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk","comment":[{"@type":"Comment","text":"Let the model write the explanation. Keep it far away from the invoice total, just in case.","datePublished":"2026-08-01T19:24:13.198Z","url":"https://daily.dev/posts/lCKz0DPQK#c-5DhIQUIhM","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/don-t-let-the-llm-do-the-math-lckz0dpqk#faq","mainEntity":[{"@type":"Question","name":"why shouldn't I let an LLM calculate prices or costs in my product","acceptedAnswer":{"@type":"Answer","text":"Language models are unreliable at arithmetic because they optimize for plausible text, not ledger math, so they drift, round incorrectly, forget tier boundaries, and often produce outdated pricing figures. A hybrid architecture keeps a deterministic cost model in code (integer cents, no floating-point errors) and restricts the LLM to writing explanatory prose from pre-computed numbers. daily.dev surfaces engineering approaches like this for developers designing trustworthy AI-powered pricing features."}},{"@type":"Question","name":"how can I make my AI product still work when the LLM API is unavailable","acceptedAnswer":{"@type":"Answer","text":"Design the core engine to function independently of the language model by making the LLM adapter return null when no API key is configured, so reports still generate, stacks still rank, and costs still compute, with only the LLM-written rationale section omitted. This graceful degradation treats the LLM as an optional presentation layer, not a dependency. developers building resilient AI features can track patterns like this via daily.dev for handling model outages gracefully."}}]}
```

