Divide int's and round up in Objective-C

前端 未结 5 847
既然无缘
既然无缘 2021-01-31 01:11

I have 2 int\'s. How do I divide one by the other and then round up afterwards?

5条回答
  •  失恋的感觉
    2021-01-31 01:43

    If you looking for 2.1 roundup> 3

    double row = _datas.count / 3;
    double rounded = ceil(_datas.count / 3);
    if(row > rounded){
        row += 1;
    }else{
    
    }
    

提交回复
热议问题