Click or drag to resize
gmp_libmpz_limbs_read Method
Return a pointer to the limb array representing the absolute value of x.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static mp_ptr mpz_limbs_read(
	mpz_t x
)

Parameters

x
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: mp_ptr
A pointer to the limb array representing the absolute value of x.
Remarks

The size of the array is mpz_size(x). Intended for read access only.

Examples
// Create and initialize new integer x.
mpz_t x = new mpz_t();
gmp_lib.mpz_init(x);

// Set the value of x.
char_ptr value = new char_ptr("10000 00000000000000000000000000000000");
gmp_lib.mpz_set_str(x, value, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 4);

// Get pointer to the limbs of x.
mp_ptr limbs = gmp_lib.mpz_limbs_read(x);

// Assert the values of the limbs based on current architecture (x86 or x64).
Assert.IsTrue(limbs[0] == 0);
Assert.IsTrue(limbs[1] == (gmp_lib.mp_bytes_per_limb == 4 ? 16U : 256U));

// Release unmanaged memory allocated for x and value.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
See Also