diff options
author | Josh Blum | 2011-10-24 14:19:23 -0700 |
---|---|---|
committer | Josh Blum | 2011-10-25 10:03:37 -0700 |
commit | 07378363172b0478a14ccac10fa1a0c1446fcfe6 (patch) | |
tree | b0a898f89ca67f083eb8bfa28c54290b57949eb9 /cmake/msvc | |
parent | e099b30869a7784e0caf806f187068b83f34dc37 (diff) | |
download | gnuradio-07378363172b0478a14ccac10fa1a0c1446fcfe6.tar.gz gnuradio-07378363172b0478a14ccac10fa1a0c1446fcfe6.tar.bz2 gnuradio-07378363172b0478a14ccac10fa1a0c1446fcfe6.zip |
msvc: fixed rint implementations in config.h
Fixed the rint and rintf functions to work properly.
Would love to use boost::math::round implementation,
but these functions also get included and used in C.
Also added llrint and llrintf just because.
Diffstat (limited to 'cmake/msvc')
-rw-r--r-- | cmake/msvc/config.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmake/msvc/config.h b/cmake/msvc/config.h index 71e94c832..43792c783 100644 --- a/cmake/msvc/config.h +++ b/cmake/msvc/config.h @@ -21,10 +21,13 @@ typedef ptrdiff_t ssize_t; //////////////////////////////////////////////////////////////////////// // rint functions //////////////////////////////////////////////////////////////////////// +#include <math.h> static inline long lrint(double x){return (long)(x > 0.0 ? x + 0.5 : x - 0.5);} static inline long lrintf(float x){return (long)(x > 0.0f ? x + 0.5f : x - 0.5f);} -static inline double rint(double x){return (double)lrint(x);} -static inline float rintf(float x){return (float)lrintf(x);} +static inline long long llrint(double x){return (long long)(x > 0.0 ? x + 0.5 : x - 0.5);} +static inline long long llrintf(float x){return (long long)(x > 0.0f ? x + 0.5f : x - 0.5f);} +static inline double rint(double x){return (x > 0.0)? floor(x + 0.5) : ceil(x - 0.5);} +static inline float rintf(float x){return (x > 0.0f)? floorf(x + 0.5f) : ceilf(x - 0.5f);} //////////////////////////////////////////////////////////////////////// // math constants |