Quote:Original post by random_thinker
OK...I stand corrected. Would something like this help:Quote:
A C Solution
Fortunately, the 1999 ISO C Standard defines two functions which were not a part of earlier versions of the standard. These functions round doubles and floats to long ints and have the following function prototypes:
long int lrint (double x) ;
long int lrintf (float x) ;
These functions are defined in <math.h> but are only usable with the GNU C compiler if C99 extensions have been enabled before <math.h> is included. This is done as follows:
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#include <math.h>
Two versions of the defines ensure that the required functions are picked up with older header files. In the GLIBC (the standard version of the C library on Linux) header files, these functions are defined as inline functions and are in fact inlined by gcc (the standard C compiler on Linux) when optimisation is switched on. If optimisation is switched off, the functions are not inlined and an executable calling these functions will need to be linked with the maths library.
--random
Not really, because these are FUNCTIONS which are computed at runtime. What is needed here is some kind of expression that as computed at compile time.
[Edited by - rozz666 on October 2, 2007 1:41:30 PM]