GMP Native Interface for .NET
gmp_libmpz_limbs_finish Method |
Updates the internal size field of x.
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)

public static void mpz_limbs_finish( mpz_t x, mp_size_t s )
Public Shared Sub mpz_limbs_finish ( x As mpz_t, s As mp_size_t )
public: static void mpz_limbs_finish( mpz_t^ x, mp_size_t s )
static member mpz_limbs_finish : x : mpz_t * s : mp_size_t -> unit
Parameters
- x
- Type: Math.Gmp.Nativempz_t
The operand integer. - s
- Type: Math.Gmp.Nativemp_size_t
The number of limbs and the sign of x.

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.
C++
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); }
