Thread: Quick Math Help
View Single Post
  #9 (permalink)  
Old 08-08-2005, 01:54 PM
rjbarlow rjbarlow is offline
Conservative Republican
 
Real Name: Bob Barlow
Location: near Fredericksburg, Virginia
Hybrids: 2004 Honda Civic w/Manual Trans
Posts: 178
Talking Re: Quick Math Help

Jason,

Now I am really treading into the unknown, I know NOTHING about computer language or programming. But what if in the third line of the partial quote below you changed ">0" to "=0" as the formula just to calculate the progress since adding tanks? Isn't that the code entry that tells the calculator that the mpg start may be something above 0, as in 23,151 miles in my case?

Bob

Quote:
Originally Posted by Jason
If any of you know PHP, maybe this could help. It's the code to calculate lifetime MPG.

[// Define car data
$mi=$car['mi_start']+$mi_tanks;
if($car['mpg_start']>0) {
$mpg=$mi / ($tanks_bit + ($car['mi_start']/$car['mpg_start']));
} elseif ($mi_tanks>0) {
$mpg=$mi_tanks / $tanks_bit;
} else {
$mpg=0;
}[/code]

.

Reply With Quote