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).
This commit is contained in:
Tim Peters 2001-09-06 21:59:14 +00:00
parent 8bce4acb17
commit e56ed9ba15
1 changed files with 2 additions and 0 deletions

View File

@ -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 */