0
正如上面所說... 我不需要秒,因爲它不會不斷更新。 我已經搜索了這個網站和谷歌幾個小時,並找不到任何完全符合我需要的東西。 這裏是我的代碼:如何將double值轉換爲hh:mm?
//Sets the percentage calculation
double percent = level/100;
//Calculates the time left while using the following
double a = 40 * percent;
double b = 400 * percent;
double c = 7 * percent;
double d = 6 * percent;
aTime.text = [NSString stringWithFormat:@"%f", a];
bTime.text = [NSString stringWithFormat:@"%f", b];
cTime.text = [NSString stringWithFormat:@"%f", c];
dTime.text = [NSString stringWithFormat:@"%f", d];
,比方說,7小時50%的計算之後,它目前提供了3.5小時。我想讓它說3:30。
正如你所看到的,計算結果是靜態減去水平計算,我只需要知道如何將小數轉換爲hh:mm(甚至可能是400小時的天)。
注意:以上所有數字(40,400,7,6)都是以小時爲單位。
[模量算術](http://en.wikipedia.org/wiki/Modulo_operation) - 在C的語言''% 。 –