From fc116d7fe95278e23f958828b7607fd642c6c6b2 Mon Sep 17 00:00:00 2001 From: vp153 Date: Mon, 5 Apr 2010 12:02:07 +0000 Subject: [PATCH] fixed cvRound implementation for MSVC on 32-bit Windows git-svn-id: https://code.ros.org/svn/opencv/trunk@2984 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08 --- opencv/include/opencv/cxtypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opencv/include/opencv/cxtypes.h b/opencv/include/opencv/cxtypes.h index e43f5edf..110219cc 100644 --- a/opencv/include/opencv/cxtypes.h +++ b/opencv/include/opencv/cxtypes.h @@ -216,7 +216,7 @@ CV_INLINE int cvRound( double value ) #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && !defined __APPLE__) __m128d t = _mm_set_sd( value ); return _mm_cvtsd_si32(t); -#elif defined _MSC_VER && defined _M_X86 +#elif defined _MSC_VER && defined _M_IX86 int t; __asm { @@ -228,7 +228,7 @@ CV_INLINE int cvRound( double value ) return (int)lrint(value); #else // while this is not IEEE754-compliant rounding, it's usually a good enough approximation - return (int)(value + 0.5); + return (int)(value + (value >= 0 ? 0.5 : -0.5)); #endif } -- 2.39.2