Initialize x, with space for n-bit numbers, and set its value to 0.
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 void mpz_init2(
mpz_t x,
mp_bitcnt_t n
)
Public Shared Sub mpz_init2 (
x As mpz_t,
n As mp_bitcnt_t
)
public:
static void mpz_init2(
mpz_t^ x,
mp_bitcnt_t n
)
static member mpz_init2 :
x : mpz_t *
n : mp_bitcnt_t -> unit
Parameters
- x
- Type: Math.Gmp.Nativempz_t
The integer. - n
- Type: Math.Gmp.Nativemp_bitcnt_t
The number of bits.
Remarks
Calling this function instead of mpz_init or mpz_inits
is never necessary; reallocation is handled automatically by GMP when needed.
While n defines the initial space, x will grow automatically in the normal way,
if necessary, for subsequent values stored.
mpz_init2 makes it possible to avoid such reallocations if a maximum size is known in advance.
In preparation for an operation, GMP often allocates one limb more than ultimately needed.
To make sure GMP will not perform reallocation for x, you need to add the number of bits
in mp_limb_t to n.
Examples
mpz_t x = new mpz_t();
gmp_lib.mpz_init2(x, 300);
Assert.IsTrue(gmp_lib.mpz_get_si(x) == 0);
gmp_lib.mpz_clear(x);
Dim x As New mpz_t()
gmp_lib.mpz_init2(x, 300)
Assert.IsTrue(gmp_lib.mpz_get_si(x) = 0)
gmp_lib.mpz_clear(x)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also