Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 
like image 856
DNB5brims Avatar asked Nov 21 '11 01:11

DNB5brims


People also ask

How do you round a number in Objective C?

float number = 12.3456; int roundedOff = lroundf(number);

What is Ceil rounding?

The Math.ceil() function always rounds up and returns the smaller integer greater than or equal to a given number.


1 Answers

You want the ceiling function. Used like so:

float roundedup = ceil(otherfloat); 
like image 167
Anthony Blake Avatar answered Sep 20 '22 23:09

Anthony Blake