Round a float up to the next integer in objective C?

前端 未结 4 1875
青春惊慌失措
青春惊慌失措 2020-12-23 16:01

How can I round a float up to the next integer value in objective C?

1.1 -> 2
2.3 -> 3
3.4 -> 4
3.5 -> 4
3.6 -> 4
1.0000000001 -> 2
         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 16:55

    Use the ceil() function.

    Someone did a little math in Objective C writeup here: http://webbuilders.wordpress.com/2009/04/01/objective-c-math/

提交回复
热议问题