Build log ·

Engineering

Open any browser console and type 0.1 + 0.2. You get 0.30000000000000004.

That isn't a bug in JavaScript. Floating-point numbers are stored in binary, and most decimal fractions — including 0.1 — can't be written exactly in binary. Every calculation carries a tiny error.

Why it matters

On one receipt, nobody notices. The total rounds to the right number and the customer walks away happy.

Across thousands of invoices, the errors add up. The month-end total stops matching the sum of the sales. The owner opens the report, sees a number that doesn't add up, and stops trusting the system.

What Nova Store does

In Nova Store, every financial field is a Decimal column in PostgreSQL, and every sale runs as one database transaction — either all of it is written, or none of it is.

model Sale {
  id        Int      @id @default(autoincrement())
  total     Decimal  @db.Decimal(12, 2)
  discount  Decimal  @db.Decimal(12, 2)
  createdAt DateTime @default(now())
}

Three rules

  1. Money is Decimal — or an integer of the smallest unit.
  2. Every financial write is a transaction.
  3. Rounding happens once, at a defined point, with a defined rule.

Have a project in mind?


Get in touch