Money and rounding
Know how Kabaido holds money (whole minor units, exact decimals, half up) so a total always equals its lines.
A price is only useful if the same inputs give the same figure every time, on the screen, on the quote and in your AI's answer. Three rules make that so.
1. Money is whole minor units and a currency#
Every amount is stored as a whole number of the currency's smallest unit, beside its currency code: £189.00 is 18900 and GBP. There is no fraction of a penny to lose and no amount without its currency.
| Shown | Stored | Currency |
|---|---|---|
| £189.00 | 18900 | GBP |
| €189.00 | 18900 | EUR |
| $189.00 | 18900 | USD |
A currency whose smallest unit is not a hundredth is held to its own: one with no minor unit is stored whole.
2. Sums run in exact decimals#
A score, a length and a factor all carry decimals, so the working cannot be whole numbers. It runs in exact decimal arithmetic, never in binary floating point, where 0.1 + 0.2 does not come to 0.3.
binary floating point 0.1 + 0.2 = 0.30000000000000004
exact decimal 0.1 + 0.2 = 0.33. Round half up, once#
A line is rounded to a whole minor unit one time, at the end of its own sum. Half a unit rounds up. A total is then whole lines added together, so it always equals the lines printed above it.
rounded = ⌊ amount + ½ ⌋
total = Σ rounded lines
- amount
- the line's exact value in minor units, before rounding
- rounded lines
- each line after its one rounding
| Exact amount | Rounded half up |
|---|---|
| £26.9249 | £26.92 |
| £26.925 | £26.93 |
| £26.9255 | £26.93 |
| £0.005 | £0.01 |
| £0.004 | £0.00 |
Unit prices and line totals#
A round tool is priced as a line for the whole quantity and the unit price is that line shared out, rounded half up. A blade is priced as a unit and a basket multiplies it. Either way the figure a customer pays is whole minor units from the first sum to the invoice.
Tax#
Prices are held before tax. On a store, tax is worked out once on the basket (the goods, less any discount, plus carriage) at the rate set for the store, and rounded half up. The figure with tax shown beside a unit price is for display.
tax = ⌊ amount before tax × rate + ½ ⌋
How it is written#
Money is printed with its sign and no space, to two places: £189.00, never £ 189. Your AI repeats a figure exactly as the tool returned it and never works out a total of its own.
Updated Something missing or unclear? Tell us