if (tm < 0)
return strcat("0:00:0", hundredths ? "0" : "");
int acc = hundredths ? 6000 : 600;
- int seconds = floor(tm + 0.5);
- int minutes = floor(seconds / acc);
- seconds -= minutes * acc;
+ tm = floor(tm + 0.5);
+ int minutes = floor(tm / acc);
+ int tm_without_minutes = tm - minutes * acc;
// NOTE: the start digit of s is a placeholder and won't be displayed
- string s = ftos(acc * 10 + seconds);
+ string s = ftos(acc * 10 + tm_without_minutes);
return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, hundredths ? 2 : 1));
}