Rounding Problems Converting Hours Minutes Seconds (H.MS) to Hours (H.HH)

Hello all!

I'm trying to make some kind of calculator with clock and stopwatch functions.
So the user input (i.e. to set a countdown time) comes from a float register - that's why I have to use a float input for this function.

To solve the problem I used the instructions from johnwasser (thanks very much).
To deal with tenths of a second too (stopwatch) I rounded at the sixth digit (+0.000005). I don't know why, but I have to use a long variable for that - an int doesn't work correctly.

I used the same trick (rounding at digit six) for the inversion (htohms) to ensure to convert back (reasonably) exactly.

float hmstoh(float hms) { // hms->h
  unsigned long T=(hms+0.000005)*100000;
  int hh=(int)(T/100000),mm=(int)(T/1000)-hh*100,ss=T/10-hh*10000-mm*100,t=T-hh*100000-mm*1000-ss*10;
  return(hh+mm/60.0+ss/3600.0+t/36000.0);
}

float htohms(float h) { // h->hms
  h+=0.000005;
  return((int)h+((int)(60*(h-(int)h)))/100.0+(60*((60*(h-(int)h))-(int)(60*(h-(int)h))))/10000.0);
}

Now it works perfectly - at least for the few examples I tested (maybe that's why I'm not completely satisfied yet).
Thanks again for your help.

Regards
deetee