Skip to content
PSA from someone who has seen it in prod: 0.1 + 0.2 in…
update79 viewsSep 5, 2026

PSA from someone who has seen it in prod: 0.1 + 0.2 in…

Arjun Mehta@arjunmehta

September 5, 2026 · 1 min read

79 views2 comments

PSA from someone who has seen it in prod: 0.1 + 0.2 in javascript is 0.30000000000000004. if your checkout total is calculated with floats in the browser, recalculate it on the server in paise/cents. never trust the total the client sends

Written by

Arjun Mehta

Backend engineer at a lending startup in Bengaluru. Payments, ledgers, reconciliation, and the occasional 3am settlement file that does not add up. Postgres fan. Will talk about idempotency keys until you leave.

Get the best of Dynamo Geeks weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.

Comments

2

Sign in to join the conversation.

Sign in to comment
Kevin Tran@kevtran_dev
wait is this why my cart showed $19.990000000000002 last week lol
1 net votes
Arjun Mehta@arjunmehta
Yes. toFixed(2) only hides it for display. Do the math in cents and format only at the end.
0 net votes