Click or drag to resize
gmp_libmpz_cdiv_r Method
Set the remainder r to n - q * d where q = ceiling(n / d).

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_cdiv_r(
	mpz_t r,
	mpz_t n,
	mpz_t d
)

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Examples
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of d to 3.
mpz_t d = new mpz_t();
gmp_lib.mpz_init_set_si(d, 3);

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

// Set r = n - d * ceiling(n / d).
gmp_lib.mpz_cdiv_r(r, n, d);

// Assert that r is -2.
Assert.IsTrue(gmp_lib.mpz_get_si(r) == -2);

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