How the Fuel Cost Calculator Works
A trip’s fuel cost is computed as fuel used = distance ÷ efficiency, then cost = fuel × price. To stay correct across conventions, every fuel-efficiency unit is normalised to litres per kilometre (L/km): US MPG → L/km = 3.785411784 ÷ (mpg × 1.609344); UK MPG → L/km = 4.54609 ÷ (mpg × 1.609344); km/L → L/km = 1 ÷ (km/L); and L/100km → L/km = (L/100km) ÷ 100. Distance is converted to kilometres (1 mile = 1.609344 km) and price to per-litre (÷ 3.785411784 for US gallons, ÷ 4.54609 for UK gallons). Litres = trip-km × L/km, total cost = litres × price-per-litre, and the tool also reports cost per km/mile, cost per person and the trip’s L/100km. All of this is a pure function in a small, unit-tested engine.
- fuel = distance ÷ efficiency; cost = fuel × price
- Internal base is litres per kilometre (L/km)
- 1 mile = 1.609344 km · 1 US gal = 3.785411784 L · 1 UK gal = 4.54609 L
- L/100km is the reciprocal of km/L: L/100km = 100 ÷ (km/L)
- All math is client-side JavaScript with no server round-trip
