diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2016-08-21 09:23:23 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2016-08-21 09:23:23 (GMT) |
commit | dc590a4cc331601c8ab5332d907ea7abccb88ded (patch) | |
tree | a81efeee86d4a79fb2fdf827c4735e799e4fb876 /Objects/longobject.c | |
parent | 164a3c822dd1da2218d7c262fdd10d092a77c422 (diff) | |
download | cpython-dc590a4cc331601c8ab5332d907ea7abccb88ded.zip cpython-dc590a4cc331601c8ab5332d907ea7abccb88ded.tar.gz cpython-dc590a4cc331601c8ab5332d907ea7abccb88ded.tar.bz2 |
Issue #25604: Fix minor bug in integer true division, which could
have caused off-by-one-ulp results on certain platforms.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 4b2b602..81f369b 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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]; |