everytime I fill up the tank, I'm given a different "miles remaining in tank" number. How does the car determine the miles left?
You may be "topping off" differently each time. I suspect this is the biggest factor you are seeing. The filler pipe holds a lot of gas.
The following is from research.
True, gasoline does expand and contract a little depending on its temperature. But filling stations store their gasoline in underground tanks, where the temperature variation during the day is much less than in the air above. The result is that the temperature of the gasoline coming out of the fuel nozzle varies very little, if at all, during any 24-hour stretch at any particular station. However, once the gas is in your car, and has been there a while, notable changes in volume can take place. The volume of liquid fuel expands and contracts with changes in temperature — quite a bit, actually — more than four times temperature's influence on water volume. Gasoline's volume changes approximately 1 percent for every 15-degree temperature change, according to the U.S. Government Accounting Office.