开发者

Rounding time in Objective C

I got the following code:

    int days = round(durationTimeInterval / D_DAY);
    int secondsLeft = durationTimeInterval - (days * D_DAY);    
    double hoursLeft = secondsLeft % D_HOUR;
    double hours = round(hoursLeft);

if seconds left is 10710 then dividing by D_HOUR give 开发者_开发知识库me 2,975 I then want to round that up to 3 hours... Am not sure how to do this? Please advise.


You could use the round function or ceil function:

ROUND
CEIL

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜