Calculation methodology
This page documents the technical decisions behind every result.
Numeric precision
- Calculations use IEEE 754 double-precision numbers, the JavaScript standard.
- To avoid binary artefacts such as 0.1 + 0.2 = 0.30000000000000004, intermediate results are normalised to 12 significant digits — far beyond the precision shown.
- Rounding happens only for display. Intermediate steps keep full precision. A ≈ sign marks a rounded value.
Rounding
| Type | Rule | Example |
|---|---|---|
| Mathematical (default) | Half away from zero | 2.345 → 2.35; −2.5 → −3 |
| Currency (money amounts) | To cents, half up | 10.005 → 10.01 |
| Banker’s (available in the library) | Half to even | 2.345 → 2.34; 2.355 → 2.36 |
Rounding works on the decimal representation, so 1.005 rounds to 1.01 as you would expect. You can choose 0–6 decimals in each calculator; money is always shown with 2.
Conventions
- Percent: P% = P/100.
- Percentage change: (new − old) ÷ |old| × 100. Using the absolute old value keeps the sign meaningful with negative numbers; a warning is shown in those cases.
- Percentage difference: |A − B| ÷ ((A + B) ÷ 2) × 100 (the most common definition).
- Chained percentages: product of factors (1 + pᵢ).
Undefined cases
We never show “NaN” or “Infinity”. We distinguish division by zero (a non-zero amount divided by zero), indeterminate forms (zero divided by zero) and out-of-range inputs (such as a discount above 100%), and explain which value to change.
Reading numbers
Calculators accept the usual formats: decimal point or comma, thousands separators (“1,234.56”, “1.234,56”, “1 234,56”), the typographic minus sign and a trailing % sign. If an input such as “1,500” could be read two ways, it is interpreted according to the page language (in English, one thousand five hundred) and the interpretation is shown under the field.
Verification
The maths library has well over a hundred automated tests covering positive and negative values, zeros, decimals, percentages above 100, reverse percentages, chained changes, rounding and number parsing in every site language. Worked examples are computed with the same library at build time.