Divide int's and round up in Objective-C

前端 未结 5 839
既然无缘
既然无缘 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 02:08

    If your ints are A and B and you want to have ceil(A/B) just calculate (A+B-1)/B.

提交回复
热议问题