How do onboard MPG computers work? Are they accurate?

My new (Dodge) truck has a digital display that shows average miles per gallon and also the number of miles I have left until my tank is empty.

What kind of sensor does this use to determine fuel consumption? Is it based on the float in the gas tank, or is there some kind of flow metering device in the fuel line?

Also, would the reading be affected by the angle of the truck going up/down hills, etc.?

I’d appreciate hearing from anyone who knows The Straight Dope on these things.

Mods, please delete this thread. Sorry for the double post.