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
精彩评论