gmp_libmpz_limbs_finish Method |
Namespace: Math.Gmp.Native
Used after writing to the limb array pointer returned by mpz_limbs_write or mpz_limbs_modify is completed. The array should contain | s | valid limbs, representing the new absolute value for x, and the sign of x is taken from the sign of s. This function never reallocates x, so the limb pointer remains valid.
void foo (mpz_t x) { mp_size_t n, i; mp_limb_t* xp; n = mpz_size(x); xp = mpz_limbs_modify(x, 2 * n); for (i = 0; i < n; i++) xp[n + i] = xp[n - 1 - i]; mpz_limbs_finish(x, mpz_sgn(x) < 0 ? - 2 * n : 2 * n); }