summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-09-20 16:26:30 +0000
committerDavid Cournapeau <cournape@gmail.com>2008-09-20 16:26:30 +0000
commitc372fc1bad92634ae05224263fa56c86fae9b380 (patch)
tree144ab6d7f9d53058d075953932660cedb6c5527c /numpy
parentbc45f6bf99ae12105f19bc7ca00469ffb9bd60f3 (diff)
downloadnumpy-c372fc1bad92634ae05224263fa56c86fae9b380.tar.gz
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).
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/math_c99.inc.src4
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/core/src/math_c99.inc.src b/numpy/core/src/math_c99.inc.src
index 542500d49..14399f699 100644
--- a/numpy/core/src/math_c99.inc.src
+++ b/numpy/core/src/math_c99.inc.src
@@ -139,8 +139,10 @@ double trunc(double x)
# 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)