Kaydet (Commit) e56ed9ba authored tarafından Tim Peters's avatar Tim Peters

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).
üst 8bce4acb
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment