Commits

Tim Peters  committed f814ea6

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).

  • Participants
  • Parent commits 4abfc17
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Objects/longobject.c

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