How the Tip Calculator Works
The calculator computes the tip as base × percent ÷ 100, where the base is either the pre-tax bill (the etiquette default) or the post-tax total (bill + tax) depending on a toggle. The grand total is bill + tax + tip. When the bill is split, each person’s total is grand total ÷ number of people and each person’s tip is tip ÷ number of people. An optional round-up nudges either the grand total or each person’s share up to the next whole currency unit, and the extra amount is absorbed by the tip so the bill and tax are never altered. Every result is produced by a pure function in a small, unit-tested engine, live in the browser.
- Tip = base × percent ÷ 100 (base = pre-tax bill or post-tax total)
- Grand total = bill + tax + tip
- Per person = grand total ÷ number of people
- Round-up is absorbed by the tip; bill and tax stay exact
- All math is client-side JavaScript with no server round-trip
