So I found this:
"Modern engines are controlled by computers that calculate how many microliters of fuel to inject into each cylinder per combustion cycle. To determine fuel efficiency, the computer keeps a running total of both the fuel delivered to the engine and the distance driven."
"Honda uses additional inputs to calculate trip mpg. “We look at the fuel-consumed data that comes from the engine-control computer, but we also track the float sensor measuring the fuel level in the tank,” says Raj Manakkal, chief engineer for electrical and infotainment devices. He also points out that, due to temperature changes, plastic fuel tanks can expand and contract by as much as a liter. On the Acura ILX, that yields a total variation of 4 percent."