LogicTrail
  • Trails
  • Check my app
  • Pricing
  • Sign in
  1. Trails
  2. /
  3. Money and secrets
  4. · 4 minutes · Pro

Off by one cent

A customer emails a screenshot: their invoice total reads £0.30000000000000004. Your accountant says the monthly totals are a few pennies off.

This answers: Why is my app's money total off by a cent? No coding needed. 3 quick decisions.

  • Payments and webhooks
  • Where your data lives
  • Debugging without panic

Checking your access…

Why is my app's money total off by a cent?

Your app is probably storing or adding money as floating-point numbers, which cannot hold most decimals exactly: 0.10 + 0.20 gives 0.30000000000000004, and small errors add up. Store money as integer cents or an exact numeric type, do the maths in cents, and send payment integer amounts in the smallest unit.

Trail of the bug
  1. Browser
  2. Your server
  3. Database

Breaks at Database: Money stored as floating point

How it works

Add 10p, ten timesCount in whole pence
0 of 10 added

What the computer holds

0

What the customer should see

£0.00

Counting in pounds with floating point drifts: ten lots of 0.1 is not quite 1. Try it.

Why AI tools write this bug

Generated schemas and cart code often use a plain number or float column for prices, because it works perfectly with round test prices.

How to fix it

  1. Change money columns to integer cents or numeric.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock

Common questions

Is rounding to two decimals enough?
It hides the symptom on screen, but sums and comparisons can still drift. Work in integer cents.

Related scenarios

  • The webhook that arrived twicePro · 5 min
  • One field, a million creditsPro · 4 min
  • Permission denied for tablePro · 4 min

More on this trail

Money and secrets: Keys, payments, webhooks, and reading what your AI changed.

Want someone to look?

We check AI-built apps for this and three other common leaks, in plain English.

Check my app
Sign in

Sign in to walk this one

3 decisions, about 4 minutes, and a prompt to check your own app for the same problem.

Sign in No password. We email you a link.

How to fix it

  1. Change money columns to integer cents or numeric.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock