diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-12-04 12:42:18 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-12-04 12:42:18 (GMT) |
commit | 33154388f9f6b202fd513a98270a4607f20b47c0 (patch) | |
tree | 2d2c880b0996e92d14e248d85e0c4d762ddb1c06 /Objects | |
parent | 11e77ffcbc4a46001ba6c509f069692b4c5d0735 (diff) | |
download | cpython-33154388f9f6b202fd513a98270a4607f20b47c0.zip cpython-33154388f9f6b202fd513a98270a4607f20b47c0.tar.gz cpython-33154388f9f6b202fd513a98270a4607f20b47c0.tar.bz2 |
Backout broken backport. (Sorry.)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 6a2af74..865c960 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -600,20 +600,10 @@ float_rem(PyObject *v, PyObject *w) #endif PyFPE_START_PROTECT("modulo", return 0) mod = fmod(vx, wx); - if (mod) { - /* ensure the remainder has the same sign as the denominator */ - if ((wx < 0) != (mod < 0)) { - mod += wx; - } - } - else { - /* the remainder is zero, and in the presence of signed zeroes - fmod returns different results across platforms; ensure - it has the same sign as the denominator; we'd like to do - "mod = wx * 0.0", but that may get optimized away */ - mod *= mod; /* hide "mod = +0" from optimizer */ - if (wx < 0.0) - mod = -mod; + /* note: checking mod*wx < 0 is incorrect -- underflows to + 0 if wx < sqrt(smallest nonzero double) */ + if (mod && ((wx < 0) != (mod < 0))) { + mod += wx; } PyFPE_END_PROTECT(mod) return PyFloat_FromDouble(mod); |