mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #25604: Fix minor bug in integer true division, which could
have caused off-by-one-ulp results on certain platforms.
This commit is contained in:
parent
164a3c822d
commit
dc590a4cc3
2 changed files with 6 additions and 2 deletions
|
@ -3893,9 +3893,9 @@ long_true_divide(PyObject *v, PyObject *w)
|
|||
/* 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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue