gmp_libmpz_mod_ui Method |
Namespace: Math.Gmp.Native
The sign of the divisor is ignored; the result is always non-negative.
mpz_mod_ui(mpz_t, mpz_t, UInt32) is identical to mpz_fdiv_r_ui(mpz_t, mpz_t, UInt32), returning the remainder as well as setting r. See mpz_fdiv_ui(mpz_t, UInt32) if only the return value is wanted.
// Create, initialize, and set the value of x to 12222. mpz_t x = new mpz_t(); gmp_lib.mpz_init_set_ui(x, 12222U); // Create, initialize, and set the value of z to 0. mpz_t z = new mpz_t(); gmp_lib.mpz_init(z); // Set z = x mod y, and return z. Assert.IsTrue(gmp_lib.mpz_mod_ui(z, x, 10000U) == 12222 % 10000); // Assert that z is 12222 mod 10000. Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000); // Release unmanaged memory allocated for x and z. gmp_lib.mpz_clears(x, z, null);