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..
I Have a value for example int value1 = 11 after dividing on 2
Share
If you always want to round up, and you have a
floatvalue, useceilf(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.