summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Hogan <christopher.hogan@intel.com>2015-09-23 15:34:49 -0500
committerChris Hogan <christopher.hogan@intel.com>2015-10-01 10:38:57 -0500
commit09bf9cc62d47bb7d0d738c70a0fbdb9ff2a13985 (patch)
tree2b7c39e793f836d04cbcecfd8192b08805161792
parentc4924a73b348545238fab661543f61cc6631e087 (diff)
downloadnumpy-09bf9cc62d47bb7d0d738c70a0fbdb9ff2a13985.tar.gz
BUG: Guarantee non-zero is 1 for switch statements
In numpy/core/src/npymath/npy_math.c.src there is a state machine sequence that assumes signbit returns either a 1 or 0. However, all the online documentation states that it will return either a 0 or a nonzero value, which seems to be determined by the OS. These changes allow the code to work with a zero or a nonzero value.
-rw-r--r--numpy/core/src/npymath/npy_math.c.src2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/npymath/npy_math.c.src b/numpy/core/src/npymath/npy_math.c.src
index b7f28bb39..7f62810d5 100644
--- a/numpy/core/src/npymath/npy_math.c.src
+++ b/numpy/core/src/npymath/npy_math.c.src
@@ -130,7 +130,7 @@ double npy_atan2(double y, double x)
return npy_atan(y);
}
- m = 2 * npy_signbit(x) + npy_signbit(y);
+ m = 2 * (npy_signbit((x)) != 0) + (npy_signbit((y)) != 0);
if (y == 0.0) {
switch(m) {
case 0: