Search code examples
iosobjective-c

Converting MPH to minute miles


I'm attempting to convert MPH into minute miles. I'm currently running code to do this by doing 60 / the miles per hour which gives me the result in minute miles.

For example 60/8mph = 7.5

However the answer I get I need to convert into minutes and seconds so that I would have 7 minutes 30 seconds. Is there a way I can get the numbers after the decimal point so I can multiply it by 60 to convert it to seconds, then add it back to the minutes.


Solution

  • You can use remainder,

    double remainder = fmod(a_double, another_double);
    

    should include <math.h>