I'm attempting to convert feet into metres by multiplying the feet (int data type) by 0.3048 since 1 foot is 0.3048 in metres.
After doing so in my function that returns a double data type, I'm attempting to print the new value using the printf command and that command is like so:
Code:
altMetres = convert_feet_to_metres(altitude);
printf("\n\tTime: %ds, Altitude: %.2dm, Position: %f'N %f'E", timeStamp, altMetres, decDegreeLat, decDegreeLon);
My Conversion function:
Code:
double convert_feet_to_metres(int feet)
{
/* one foot is 0.3048 in metres */
return (feet * 0.3048);
}
When the value stored in altitude is 3566, the above code prints the following after my function is invoked, something weird is happening, why is Altitude -845249564 and not 1086.9168. I'm using the %.2d (format specifier) in a poor attempt to get the value (when correct calculation is done) to output 1086.92 since I need two decimal places, I ain't got this far since the calculation is all wrong.
Time: 1106059583s, Altitude: -845249564m, Position: 0.000000'N -0.000000'E
If anyone can give us a hint, would be most appreciated.