Splitting a restaurant bill sounds like simple division. It isn't. When we built a bill splitter at TechnBean, the maths turned out to be the easy part. Fairness and rounding were the hard parts.
Equal split vs. pay for what you ate
Four friends, one dinner, a $133.56 bill with tax and tip:
| Person | Equal split | Pay for what you ate | Difference |
|---|---|---|---|
| Sara | $33.39 | $26.46 | -$6.93 |
| Omar | $33.39 | $55.44 | +$22.05 |
| Lina | $33.39 | $17.64 | -$15.75 |
| Adam | $33.39 | $34.02 | +$0.63 |
An equal split quietly makes Lina pay almost 50% more than she ate.
Three fair methods
- Equal: total / people. Fine when orders are similar.
- Itemized: each person's subtotal, then tax and tip shared proportionally:
const share = (subtotal, billSubtotal, extras) =>
subtotal + extras * (subtotal / billSubtotal);
- Hybrid: shared plates split evenly across the people who had them, personal items itemized.
The leftover-cent problem
$100 / 3 = 33.333... If you round every share independently, the shares no longer add up to the receipt. Work in integer cents, give everyone the floor, then hand out the leftover cents one by one:
function splitCents(totalCents, n) {
const base = Math.floor(totalCents / n);
const extra = totalCents - base * n;
return Array.from({ length: n }, (_, i) => base + (i < extra ? 1 : 0));
}
splitCents(10000, 3); // [3334, 3333, 3333]
Try it
We packaged all of this into a free, no-sign-up web tool that runs in the browser and works in 6 languages: Smart Bill Splitter.
TechnBean builds apps and websites, designs UX and ships agentic AI products. The bill splitter is one of our free side tools.



Top comments (0)