开发者

Rounding time in Objective C

开发者 https://www.devze.com 2023-03-11 02:14 出处:网络
I got the following code: int days = round(durationTimeInterval / D_DAY); int secondsLeft = durationTimeInterval - (days * D_DAY);

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

精彩评论

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