Around the float to the next integer in the lens C?

How can I concatenate a float to the next integer value in a C object?

1.1 -> 2 2.3 -> 3 3.4 -> 4 3.5 -> 4 3.6 -> 4 1.0000000001 -> 2 
+51
floating-point objective-c int
Nov 21 '11 at 1:19
source share
3 answers

You need a ceiling function. Used like this:

 float roundedup = ceil(otherfloat); 
+113
Nov 21 '11 at 1:21
source share

Use the ceil() function.

Someone did a little math in an Objective-C entry here: http://webbuilders.wordpress.com/2009/04/01/objective-c-math/

+2
Nov 21 '11 at 1:22
source share

I just could not comment on Davids' answer. His second answer will not work, since modulo does not work with floating point values. Doesn't it look like

 if (originalFloat - (int)originalFloat > 0) { originalFloat += 1; round = (int)originalFloat; } 
+2
Mar 18 '13 at 9:55
source share



All Articles