Bear in mind: you have to cast your numbers to play with them in Objective-C!

Yes, I’m still a newbie when it comes to Objective-C, although I’ve reached a pretty good knowledge level and I’m able to build interfaces, working with files and folders, SQLite api, low level core graphics api and so on, there is always something new to learn that I was ignoring it!
Today I lost more than an hour to understand why a number didn’t get rounded properly. In a method of a class, I was using the ceil() function to round a number returned by a simple division (11/3). The unbelievable thing was that it returned 3 rather than 4 (the right value I was expecting). After several debugging and googling, I realized that I have simply to specify (cast) the numbers I’m going to divide as float to get the right value back from the division!
To specify numbers as floating values, we can use the “.f” syntax or a normal cast, the following code show the scenario:

// wrong way (it will print: "result: 0.000000 - ceiling: 3 - flooring: 12376")
NSLog(@"result: %f - ceiling: %i - flooring: %i", 
11/3, 
(NSUInteger)ceil(11/3), 
(NSUInteger)floor(11/3));

// right 1 (it will print "result: 3.666667 - ceiling: 4 - flooring: 3")
NSLog(@"result: %f - ceiling: %i - flooring: %i", 
11.0f/3.0f, 
(NSUInteger)ceil(11.0f/3.0f), 
(NSUInteger)floor(11.0f/3.0f));

// right 2 (it will print "result: 3.666667 - ceiling: 4 - flooring: 3")
NSLog(@"result: %f - ceiling: %i - flooring: %i", 
(float)11/(float)3, 
(NSUInteger)ceil((float)11/(float)3), 
(NSUInteger)floor((float)11/(float)3));