diff options
author | Chris Hogan <christopher.hogan@intel.com> | 2015-09-23 15:34:49 -0500 |
---|---|---|
committer | Chris Hogan <christopher.hogan@intel.com> | 2015-10-01 10:38:57 -0500 |
commit | 09bf9cc62d47bb7d0d738c70a0fbdb9ff2a13985 (patch) | |
tree | 2b7c39e793f836d04cbcecfd8192b08805161792 /numpy | |
parent | c4924a73b348545238fab661543f61cc6631e087 (diff) | |
download | numpy-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.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/npymath/npy_math.c.src | 2 |
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: |