mirror of https://github.com/python/cpython
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:
parent
8bce4acb17
commit
e56ed9ba15
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue