Electric Vehicle Forums

Electric Vehicle Forums (/forums/)
-   Fuel Economy & Emissions (https://electricvehicleforums.com/forums/fuel-economy-emissions-22/)
-   -   Imperial gallons? (https://electricvehicleforums.com/forums/fuel-economy-emissions-22/imperial-gallons-481/)

3cyl 05-17-2004 07:53 PM

I noticed the top car on the mileage chart is located in the UK. A gallon in the UK is an imperial gallon, about 1.2x a US gallon. Using an online calculator I found at http://hemsidor.torget.se/users/b/bohjohan...ert/conv2_e.htm his mean mileage comes to about 83 US mpg. Perhaps the database should have some way of adjusting for this, or did I miss mention of this somewhere else?

Jason 05-17-2004 07:57 PM

Yes. The database compensates for this. When you enter data, you can select "Imperial Gallons". The value is mathematically calculated and inserted in US gal in the database.

Code:

if ($_POST['mileage_unit2'] == 'liter') {
        $mileage = $mileage*3.785;
 } elseif ($_POST['mileage_unit2'] == 'imperialgallon') {
        $mileage = $mileage*1.201;
 }

There's some computer code for you. Basically says that if they select "liter", multiply by 3.785. If "imperial gallon", by 1.201.

Jason 05-17-2004 08:00 PM

Oh, and I don't quite understand your conversion. That should be 83 Imperial gallons, methinks.

Jason 05-17-2004 08:02 PM

Ah! Oh, no! I have it backwards!

It should be DIVIDING by 1.2

Great. Guess I better fix this and do some manual calculations to fix the data.

Jason 05-17-2004 08:12 PM

I'm changing it to the following. I'll change his data so that I'm assuming he used kilometers and Imperial gallons. Is that a good assumption?

To interpret, ignore the $ and $_POST. Between {}s means "Do this". = is to define. == is to see if it's true.

Code:

$mileage = $_POST['mileage_integers'].'.'.$_POST['mileage_tenths'];
 if ($_POST['mileage_unit1'] == 'km') {
        $mileage = $mileage*1.609;
 }
 if ($_POST['mileage_unit2'] == 'liter') {
        $mileage = $mileage*3.785;
 } elseif ($_POST['mileage_unit2'] == 'imperialgallon') {
        $mileage = $mileage/1.201;
 }
 $mileage = round($mileage,1);
 
 if ($_POST['distance_unit'] == 'km') {
        $distance = round($_POST['distance']*1.609);
 } else {
        $distance = $_POST['distance'];
 }


Jason 05-17-2004 08:20 PM

Okay. He's back in his rightful place. I didn't change the distances, as I really don't know if he used miles or kilometers. There isn't a significant difference.

I'll need to double check my code for future use. Thank you very much for pointing it out!

Jason 05-17-2004 08:27 PM

On second thought, I'll probably change it as if he initially put KM because using 7 gallons on a tank isn't normal. The average for insights seems to be about 11.

Ooh! I need to do some heavy thinking tomorrow :( The data is all wrong for him, and I don't want to just delete it.

aplumb 05-21-2004 07:13 AM

Just noticed these issues for myself; passed it on to Jason and he put up the notice to use miles and US Gallons.

For the benefit of those of us using metric:

1.0 litres = 0.264172051 US gallons
1.0 kilometer = 0.621371192 miles

Gotta love Google's built-in calculator!

Andrew.

Jason 05-21-2004 07:14 AM

Yes, for now. I'll fix it later today. But, it's really a mind boggler figuring out what to do with the numerator and denominator individually. Eek!

aplumb 05-21-2004 08:06 AM

...and of course as an added wrinkle we don't actually measure fuel consumption performance in km/L. It's "L/100km"; on Google you can enter in something like:

50 miles per gallon in L/100km

...and get back...

50 miles per gallon = 4.70429169 L/100km

Or in my case as an example, my best ever trip I averaged 4.0L/100km on a 600km summer trip (from Ottawa to Kingston and back), average speed of 80km/h:

4.0 L/100km in miles per US gallon

...gives me...

4.0 L/100km = 58.8036461 miles per US gallon

So, all that is my long-winded way of saying, until Jason has the time iron out the bugs, those of us using other units can do the calculations via Google. :)

Great place you have here, Jason!

Andrew.


All times are GMT -7. The time now is 05:06 PM.


© 2024 MH Sub I, LLC dba Internet Brands