Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aleaxit/gmpy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a3c41752ce265d1bea21fccd13f016aee558df31
Choose a base ref
..
head repository: aleaxit/gmpy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fbf99e63d591b1e348f6ea08af4f99eebd45f816
Choose a head ref
Showing with 3 additions and 4 deletions.
  1. +3 −4 src/gmpy2_convert_gmp.c
7 changes: 3 additions & 4 deletions src/gmpy2_convert_gmp.c
Original file line number Diff line number Diff line change
@@ -133,8 +133,7 @@ GMPy_PyLong_From_MPZ(MPZ_Object *obj, CTXT_Object *context)

/* Assume gmp uses limbs as least as large as the builtin longs do */

size_t count, size = (mpz_sizeinbase(obj->z, 2) +
PyLong_SHIFT - 1) / PyLong_SHIFT;
size_t size = (mpz_sizeinbase(obj->z, 2) + PyLong_SHIFT - 1) / PyLong_SHIFT;
PyLongObject *result;

if (!(result = _PyLong_New(size))) {
@@ -143,10 +142,10 @@ GMPy_PyLong_From_MPZ(MPZ_Object *obj, CTXT_Object *context)
/* LCOV_EXCL_STOP */
}

mpz_export(GET_OB_DIGIT(result), &count, -1, sizeof(digit), 0,
mpz_export(GET_OB_DIGIT(result), NULL, -1, sizeof(digit), 0,
sizeof(digit)*8 - PyLong_SHIFT, obj->z);

_PyLong_SetSignAndDigitCount(result, mpz_sgn(obj->z) < 0, count);
_PyLong_SetSignAndDigitCount(result, mpz_sgn(obj->z) < 0, size);

return (PyObject*)result;
}