1. 15 2月, 2021 11 次提交
  2. 14 2月, 2021 2 次提交
  3. 13 2月, 2021 3 次提交
  4. 12 2月, 2021 9 次提交
  5. 11 2月, 2021 2 次提交
  6. 09 2月, 2021 1 次提交
  7. 08 2月, 2021 1 次提交
    • D
      py/mpz: Fix overflow of borrow in mpn_div. · 0a599385
      Damien George 提交于
      For certain operands to mpn_div, the existing code path for
      `DIG_SIZE == MPZ_DBL_DIG_SIZE / 2` had a bug in it where borrow could still
      overflow in the `(x >= *n || *n - x <= borrow)` branch, ie
      `borrow + x - (mpz_dbl_dig_t)*n` overflows the borrow variable.  In such
      cases the subsequent right-shift of borrow would not bring in the overflow
      bit, leading to an error in the result.  An example division that had
      overflow when MPZ_DIG_SIZE = 16 is `(2 ** 48 - 1) ** 2 // (2 ** 48 - 1)`.
      
      This is fixed in this commit by simplifying the code and handling the low
      digits of borrow first, and then the upper bits (to shift down) separately.
      There is no longer a distinction between `DIG_SIZE < MPZ_DBL_DIG_SIZE / 2`
      and `DIG_SIZE == MPZ_DBL_DIG_SIZE / 2`.
      
      This commit also simplifies the second part of the calculation so that
      borrow does not need to be negated (instead the code just works knowing
      that borrow is negative and using + instead of - in calculations involving
      borrow).
      
      Fixes #6777.
      Signed-off-by: NDamien George <damien@micropython.org>
      0a599385
  8. 05 2月, 2021 1 次提交
  9. 04 2月, 2021 8 次提交
  10. 02 2月, 2021 2 次提交