Transparency
Methodology and research status
This page documents what the calculators do, how the formulas are tested, which constants are used, and what has deliberately not been published yet.
Formula library and constants
All calculations live in src/lib/calculations.ts. The main constants are:
| Constant | Value | Use |
|---|---|---|
| Imperial gallon | 4.54609 L | UK MPG and UK fuel cost |
| US gallon | 3.785411784 L | US MPG and US fuel cost |
| Mile | 1.609344 km | Distance conversion |
| MPG UK factor | 282.480936 | L/100 km ↔ MPG UK |
| MPG US factor | 235.214583 | L/100 km ↔ MPG US |
| Mechanical horsepower | 745.6998716 W | hp and bhp conversions |
| Metric horsepower | 735.49875 W | PS conversions |
| Gasoline-equivalent energy | 33.7 kWh/US gal | MPGe conversions |
The MPG factors are derived from the gallon and mile definitions rather than stored as unexplained magic numbers. The 33.7 kWh figure follows the EPA gasoline-equivalent basis; EPA MPGe includes charging losses. See the MPGe guide.
Verification approach
Each conversion has an independent test with a known expected value. Tests also cover zero, negative, missing and boundary inputs, and the four market paths (UK, US, EU, CH). The current suite has 40 tests. It runs with npm test.
A test passing means the code matches the documented formula. It does not validate a user’s fuel price, a vehicle’s real-world consumption, a tariff or a regulation.
| Formula | Test | Status |
|---|---|---|
| L/100 km → MPG UK | 5 L/100 km → 56.50 MPG UK | Passing |
| L/100 km → MPG US | 5 L/100 km → 47.04 MPG US | Passing |
| UK fuel cost | 100 mi, 50 MPG UK, 145p/l → £13.18 | Passing |
| US fuel cost | 300 mi, 30 MPG US, $3.50/gal → $35.00 | Passing |
| EU fuel cost | 500 km, 6.5 L/100 km, €1.75/l → €56.88 | Passing |
| CH fuel cost | 500 km, 6.5 L/100 km, CHF 1.75/l → CHF 56.88 | Passing |
| EV charging | 45 kWh battery, 90% efficiency, 25p/kWh → £12.50 | Passing |
| EV vs petrol | 10,000 mi, 50 MPG UK vs 3.5 mi/kWh → annual difference | Passing |
| kW ↔ PS ↔ hp | 100 kW → 135.96 PS / 134.10 hp | Passing |
| Zero input handling | 0 L/100 km → infinite MPG | Passing |
| Invalid input handling | Negative and zero denominators rejected or flagged | Passing |
Unit policy
- UK defaults: miles, MPG UK, pence per litre, GBP.
- US defaults: miles, MPG US, dollars per US gallon, USD.
- Europe defaults: kilometres, L/100 km, euros per litre, EUR.
- Switzerland defaults: kilometres, L/100 km, Swiss francs per litre, CHF.
- MPG is never shown without its system when the system matters.
- MPGe is identified as an EPA energy-equivalence rating, not liquid-fuel MPG.
- PS, hp and bhp are identified separately; bhp is treated as mechanical hp with a caveat.
Data policy
Fuel prices, electricity prices and vehicle efficiency are inputs. The site does not publish a national price, a live station price, a vignette price, a toll price or a tax rate in this build. This avoids presenting stale or invented data as current.
If a time-sensitive page is added later, it must state the jurisdiction, vehicle category, effective date, official source URL, date checked and known caveats. It must also have a maintenance owner and update trigger.
Deferred work
The following candidates were not published because they depend on official data or verification that is not in place:
- Austria, Switzerland and Slovenia vignette price/validity pages.
- UK VED, MOT, ULEZ, LEZ, Congestion Charge, Dartford and M6 Toll pages.
- US toll, turnpike and state EV registration-fee pages.
- IRS standard mileage rate and HMRC approved mileage-rate pages.
- EV charging-time, home-charger installation and tariff-comparison tools.
- Depreciation, financing, insurance and total-cost-of-ownership models.
- Country-specific translated pages and local-language keyword clusters.
- Programmatic number-specific URLs. Numeric examples are handled inside the converters.
Each requires a source record, a last-verified date, a maintenance process and, for regulatory pages, a clear separation between official requirements and estimates.
Maintenance
On any formula change: update the library, update the tests, update the formula text and the verification log, then record the change in the corrections log. Do not change a date without checking the page. Do not add a year-specific page unless the information genuinely differs by year.
Primary references
- NIST — unit conversion — US customary and metric relationships.
- US EPA — fuel economy and EV range testing — MPGe basis and charging-loss treatment.
- fueleconomy.gov — US EPA / Department of Energy fuel-economy labels.
- GOV.UK — weekly road fuel prices — UK fuel price statistics.
Page last reviewed: . Formulas are covered by automated tests. Prices are inputs, not live data.