[Numpy-svn] r5852 - branches/clean_math_config/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Sep 20 11:26:34 CDT 2008


Author: cdavid
Date: 2008-09-20 11:26:30 -0500 (Sat, 20 Sep 2008)
New Revision: 5852

Modified:
   branches/clean_math_config/numpy/core/src/math_c99.inc.src
Log:
Fix for isfinite on VS 2003.

VS 2003 seems to think it is ok to simplify x-x to 0 for float, but this is
wrong for NaN and Inf. To  alleviate, we force the operation to occur with (x)
+ (-x).


Modified: branches/clean_math_config/numpy/core/src/math_c99.inc.src
===================================================================
--- branches/clean_math_config/numpy/core/src/math_c99.inc.src	2008-09-20 16:13:48 UTC (rev 5851)
+++ branches/clean_math_config/numpy/core/src/math_c99.inc.src	2008-09-20 16:26:30 UTC (rev 5852)
@@ -139,8 +139,10 @@
     # define isnan(x) ((x) != (x))
 #endif
 
+/* VS 2003 with /Ox optimizes (x)-(x) to 0, which is not IEEE compliant. So we
+ * force (x) + (-x), which seems to work. */
 #if !defined(HAVE_DECL_ISFINITE)
-    # define isfinite(x) !isnan((x) - (x))
+    # define isfinite(x) !isnan((x) + (-x))
 #endif
 
 #if !defined(HAVE_DECL_ISINF)



More information about the Numpy-svn mailing list