Click or drag to resize
gmp_libmpz_tdiv_q_2exp Method
Set the quotient q to trunc(n / 2^b).

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_tdiv_q_2exp(
	mpz_t q,
	mpz_t n,
	mp_bitcnt_t b
)

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
b
Type: Math.Gmp.Nativemp_bitcnt_t
The exponent of the power of two denominator.
Examples
// Create, initialize, and set the value of n to 10001.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10001);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = trunc(n / 2^2).
gmp_lib.mpz_tdiv_q_2exp(q, n, 2U);

// Assert that q is trunc(10001 / 4).
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 2500);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
See Also