diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-06 21:59:14 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-06 21:59:14 (GMT) |
commit | e56ed9ba1513b3719ce0fe8b85da6b3367d7da64 (patch) | |
tree | b2c6af7466a17148f03a1a21cb86cac253a9e654 /Objects/longobject.c | |
parent | 8bce4acb17ee7146c5736ad020ea0e129bd7f67b (diff) | |
download | cpython-e56ed9ba1513b3719ce0fe8b85da6b3367d7da64.zip cpython-e56ed9ba1513b3719ce0fe8b85da6b3367d7da64.tar.gz cpython-e56ed9ba1513b3719ce0fe8b85da6b3367d7da64.tar.bz2 |
long_true_divide: reliably force underflow to 0 when the denominator
has more bits than the numerator than can be counted in a C int (yes,
that's unlikely, and no, I'm not adding a test case with a 2 gigabit
long).
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index e9e408d..c7608aa 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1605,6 +1605,8 @@ long_true_divide(PyObject *v, PyObject *w) aexp -= bexp; if (aexp > INT_MAX / SHIFT) goto overflow; + else if (aexp < -(INT_MAX / SHIFT)) + return PyFloat_FromDouble(0.0); /* underflow to 0 */ errno = 0; ad = ldexp(ad, aexp * SHIFT); if (Py_OVERFLOWED(ad)) /* ignore underflow to 0.0 */ |