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
float number = 12.3456; int roundedOff = lroundf(number);
The Math.ceil() function always rounds up and returns the smaller integer greater than or equal to a given number.
You want the ceiling function. Used like so:
float roundedup = ceil(otherfloat);
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