From 07378363172b0478a14ccac10fa1a0c1446fcfe6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 24 Oct 2011 14:19:23 -0700 Subject: 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. --- cmake/msvc/config.h | 7 +++++-- 1 file 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 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 -- cgit