   Average speed calc
  i'm trying to work out the average speed of a moving object in mphi have the object distance travelled, i have the time in secs so is the equation like the code below correct?float Game_CalcAvSpeedMPH(float fTime, float fDistance){   float fAvSpeed = 0.0f;  // Average speed = Distance / Time  fTime /= 60;  fTime /= 60;    return (fAvSpeed = fDistance / fTime); }
  What units does fDistance use?Why do you need fAvSpeed there? Do you fear directly returning the result of a computation?   ;  the distance is in miiles, i use fDistance for debugging more than anything to track the variable   ;  Your function seems correct. Why do you define a local variable that has two assignments but whose value you never use?Also, division is an expensive operation. Instead of dividing the denominator by 3600, you can just multiply the numerator by 3600.float Game_CalcAvSprrdMPH(float fTime, float fDistance){  return 3600.0f * fDistance / fTime;}