changeset: 102824:b9e12ca6fdb6 user: Mark Dickinson date: Sun Aug 21 10:23:23 2016 +0100 files: Misc/NEWS Objects/longobject.c description: Issue #25604: Fix minor bug in integer true division, which could have caused off-by-one-ulp results on certain platforms. diff -r c7f9e66826a0 -r b9e12ca6fdb6 Misc/NEWS --- a/Misc/NEWS Sun Aug 21 09:31:44 2016 +0100 +++ b/Misc/NEWS Sun Aug 21 10:23:23 2016 +0100 @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #25604: Fix a minor bug in integer true division; this bug could + potentially have caused off-by-one-ulp results on platforms with + unreliable ldexp implementations. + - Issue #27662: Fix an overflow check in ``List_New``: the original code was checking against ``Py_SIZE_MAX`` instead of the correct upper bound of ``Py_SSIZE_T_MAX``. Patch by Xiang Zhang. diff -r c7f9e66826a0 -r b9e12ca6fdb6 Objects/longobject.c --- a/Objects/longobject.c Sun Aug 21 09:31:44 2016 +0100 +++ b/Objects/longobject.c Sun Aug 21 10:23:23 2016 +0100 @@ -3893,9 +3893,9 @@ /* Round by directly modifying the low digit of x. */ mask = (digit)1 << (extra_bits - 1); low = x->ob_digit[0] | inexact; - if (low & mask && low & (3*mask-1)) + if ((low & mask) && (low & (3U*mask-1U))) low += mask; - x->ob_digit[0] = low & ~(mask-1U); + x->ob_digit[0] = low & ~(2U*mask-1U); /* Convert x to a double dx; the conversion is exact. */ dx = x->ob_digit[--x_size];