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

DNB5brims picture DNB5brims · Nov 21, 2011 · Viewed 51.6k times · Source

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

Answer

Anthony Blake picture Anthony Blake · Nov 21, 2011

You want the ceiling function. Used like so:

float roundedup = ceil(otherfloat);