Skip to content
update

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

Arjun Mehta@arjunmehta

September 5, 2026

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

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