Private float value ios
4 answers
there are ceil (<# (double) #>) or ceilf (<# (float) #>) functions that round the value up
Also, you must explicitly use float / double calculations to get 5.5, which can be rounded up.
ceilf(value1 / 2.0f);
or
ceilf(1.0f * value1 / 2);
If you don't, it can be presented in the following sequence:
ceilf(11/2) =
1) 11/2 = result int = 5
2) ceilf(5)
3) 5 ->int implicitly cast to float -> 5.0f
4) result 5.0f
+9
source to share