{
  "id": "gas-mileage",
  "version": "c5ff0bfa8be8",
  "status": "published",
  "name": "Gas Mileage Calculator",
  "question": "What is my gas mileage?",
  "summary": "Works out a car’s gas mileage from the distance driven and the fuel used, in miles per gallon (US and UK), liters per 100 km, km per liter, and gallons per 100 miles.",
  "category": "everyday-life",
  "subcategory": "travel-and-fuel",
  "url": "https://www.acalculator.org/everyday-life/gas-mileage-calculator",
  "markdown": "https://www.acalculator.org/everyday-life/gas-mileage-calculator.md",
  "kind": "function",
  "method": "mpg = miles driven ÷ gallons used; L/100 km = liters used ÷ kilometers driven × 100",
  "assumptions": [
    "Fill the tank completely both times, so the fuel you add equals the fuel used since the last fill.",
    "A US gallon is 3.785411784 L, a UK gallon 4.54609 L, and a mile 1.609344 km, all exact.",
    "Results are exact from the typed numbers and show to 2 decimal places, rounded half up."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "dist": {
        "title": "Distance driven",
        "description": "The distance driven since the tank was last filled: new odometer reading − old reading.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "length",
        "minimum": 1,
        "maximum": 1000000000
      },
      "fuel": {
        "title": "Fuel used",
        "description": "The fuel it took to fill the tank again.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "volume",
        "minimum": 0.000001,
        "maximum": 1000000
      }
    }
  },
  "outputs": {
    "mpg": {
      "label": "Miles per gallon",
      "description": "Miles driven ÷ US gallons used.",
      "format": "number"
    },
    "l100": {
      "label": "Liters per 100 km",
      "description": "Liters used for every 100 kilometers: liters ÷ kilometers × 100.",
      "format": "number"
    },
    "kml": {
      "label": "Kilometers per liter",
      "description": "Kilometers driven ÷ liters used.",
      "format": "number"
    },
    "mpgUk": {
      "label": "Miles per UK gallon",
      "description": "Miles driven ÷ imperial gallons (4.54609 L) used.",
      "format": "number"
    },
    "gal100": {
      "label": "Gallons per 100 miles",
      "description": "US gallons used for every 100 miles, as on the EPA fuel economy label.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "dist": 482803.2,
      "fuel": 0.03785411784
    },
    "outputs": {
      "mpg": 30,
      "l100": 7.840486111111111,
      "kml": 12.75431122290816,
      "mpgUk": 36.028497765145644,
      "gal100": 3.3333333333333335
    },
    "text": "300 mi on 10 gal is 30 mpg, or 7.84 L/100 km."
  },
  "examples": [
    {
      "given": {
        "dist": 573248.3328,
        "fuel": 0.051103059084
      },
      "expect": {
        "mpg": 26.385185185185183,
        "l100": 8.914645915216171,
        "gal100": 3.790005614823133
      },
      "source": "fueleconomy.gov, Calculating Your MPG: 356.2 miles ÷ 13.5 gallons = 26.4 mpg (https://fueleconomy.gov/mpg/MPG.do?action=calcMPG); Python 3 cross-check in docs/progress/WP-56.md"
    },
    {
      "given": {
        "dist": 482803.2,
        "fuel": 0.03785411784
      },
      "expect": {
        "mpg": 30,
        "l100": 7.840486111111111,
        "kml": 12.75431122290816,
        "mpgUk": 36.02849776514565
      },
      "source": "NIST SP 811 (2008), Appendix B: 1 gal = 3.785411784 L and 1 mi = 1.609344 km exactly; hand calculation in content.mdx"
    },
    {
      "given": {
        "dist": 500000,
        "fuel": 0.04
      },
      "expect": {
        "l100": 8,
        "kml": 12.5,
        "mpg": 29.401822916666664
      },
      "source": "hand calculation in content.mdx: 40 L ÷ 500 km × 100 = 8 L/100 km; NIST SP 811 (2008), Appendix B"
    }
  ],
  "sources": [
    "U.S. Department of Energy and U.S. EPA, fueleconomy.gov, Calculating Your MPG: miles driven ÷ gallons used, with the 356.2 miles on 13.5 gallons example. https://fueleconomy.gov/mpg/MPG.do?action=calcMPG",
    "NIST SP 811 (2008), Appendix B: 1 US gallon = 3.785411784 L and 1 mile = 1.609344 km exactly.",
    "Weights and Measures Act 1985 (UK), Schedule 1: 1 gallon = 4.54609 liters."
  ],
  "related": [
    "gas",
    "mileage",
    "distance"
  ],
  "changelog": [
    {
      "date": "2026-09-30",
      "note": "Metric heads the result with litres per 100 km; the answer names L/100 km and km/L first."
    }
  ]
}
