I Have a value for example int value1 = 11 after dividing on 2 (value1 / 2) its returning 5. Real value in float is 5.5, can anybody help me to return 6 in this case, or another case..? In general, I want to round the value to the next higher..
If you always want to round up, and you have a float value, use ceilf (from the <math.h> library).
If you want to round up an integer division by n, do (value + n-1) / n. So, for a division by 2, this becomes (value + 1) / 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With