Converts fuel economy between mpg (US), mpg (UK), L/100km, and km/L, correctly inverting the L/100km reciprocal rate.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
value (number, from_unit, required) min 0 : The fuel economy figure to convert
from_unit (string, required) one of: mpg_us, mpg_uk, l_100km, km_l : Unit of the input value
to_unit (string, required) one of: mpg_us, mpg_uk, l_100km, km_l : Unit to convert into
Outputs
result (to_unit): The converted fuel economy figure
Steps
Convert the input to km/L (the pivot unit): km/L = value directly if already km/L; km/L = 100/value if L/100km (an inversion, since L/100km is a reciprocal rate); km/L = value * 1.609344/3.785411784 if mpg (US); km/L = value * 1.609344/4.54609 if mpg (UK).
Convert km/L to the target unit: value = km/L directly if km/L; value = 100/(km/L) if L/100km (an inversion); value = km/L * 3.785411784/1.609344 if mpg (US); value = km/L * 4.54609/1.609344 if mpg (UK).
Round result to 6 significant figures.
Constants
km_per_mile = 1.609344 km/mi (source: Guide for the Use of the International System of Units (SI))
liters_per_us_gallon = 3.785411784 L/gal (source: Specifications, Tolerances, and Other Technical Requirements for Weighing and Measuring Devices)
liters_per_uk_gallon = 4.54609 L/gal (source: Specifications, Tolerances, and Other Technical Requirements for Weighing and Measuring Devices)
Sources
Guide for the Use of the International System of Units (SI) (National Institute of Standards and Technology, 2026-09-30T19:29:48Z) - Exact length definition used to convert miles to kilometers.
Specifications, Tolerances, and Other Technical Requirements for Weighing and Measuring Devices (National Institute of Standards and Technology, 2026-09-30T19:29:48Z) - Exact volume definitions used for mpg (US) and mpg (UK).