On Tue, Jun 24, 2014 at 07:32:10PM +0200, FRIGN wrote:
> We are dealing with floats with at most 2 decimal places. I propose we
> just go for
> 
> CEIL(x) ((int)(x) + ((x) > 0 && (int)(x) != (x)))
> 

Well, if we know that much already then the easiest to read version
would be:

#define CEIL(x) ((int)(x >= 0? x + .99 : x))

And done! That should returns 3 when anything between 2.01 and 3.01 is
entered (excluding the upper boundary).

Alternatively:

#define INSIGNIFICANT 1e-2 /* values and differences below this don't matter */
#define CEIL(x) ((int)(x >= 0? x + 1 - INSIGNIFICANT : x))

That's easier to adjust.

Ciao,
Markus

Reply via email to