How to Split a Bill

Divides a total between people and rounds each share to the unit you choose. Rounding up leaves the organiser with a surplus, rounding down leaves them out of pocket. That difference is also shown.

The total is divided between everyone and each share is rounded to a unit you choose, so that nobody has to hand over small change.

e=u×snue = u \times \left\lceil \dfrac{s}{n u} \right\rceil

ss is the total, nn the number of people, uu the rounding unit and ee what each person pays. Choosing to round down replaces the ceiling with a floor. The amount collected, nene, and the difference from the total, nesne - s, are shown as well.

Example

A total of 23000 between 7 people is about 3285.7 each. Rounded up to the nearest 100 that becomes 3300. Seven people paying 3300 hand over 3300×7=231003300 \times 7 = 23100, which is 100 more than the bill, so 100 is left over.

Rounding up or down

Rounding up collects more than the bill and leaves a surplus. Rounding down collects less, and whoever is organising covers the shortfall. The sign of the difference says which it is: positive is a surplus, negative comes out of the organiser's pocket.

To avoid rounding altogether, set the unit to 1.

Notes

The number of people must be a whole number of at least 1, and the rounding unit must be positive.

No allowance is made for the organiser paying extra, or for a smaller share for anyone who did not drink. Everyone pays the same.