Click or drag to resize
gmp_libmpz_rootrem Method
Set root to the truncated integer part of the nth root of u. Set rem to the remainder, u - root^n.

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_rootrem(
	mpz_t root,
	mpz_t rem,
	mpz_t u,
	uint n
)

Parameters

root
Type: Math.Gmp.Nativempz_t
The result root integer.
rem
Type: Math.Gmp.Nativempz_t
The result remainder integer.
u
Type: Math.Gmp.Nativempz_t
The first operand integer.
n
Type: SystemUInt32
The second operand integer.
Examples
// Create, initialize, and set the value of u to 10000.
mpz_t u = new mpz_t();
gmp_lib.mpz_init_set_si(u, 10000);

// Create, initialize, and set the values of root and rem to 0.
mpz_t root = new mpz_t();
mpz_t rem = new mpz_t();
gmp_lib.mpz_inits(root, rem, null);

// Set root = trunc(cbrt(10000)) and rem = u - root.
gmp_lib.mpz_rootrem(root, rem, u, 3U);

// Assert that root is 21, and rem is 739.
Assert.IsTrue(gmp_lib.mpz_get_si(root) == 21);
Assert.IsTrue(gmp_lib.mpz_get_si(rem) == 739);

// Release unmanaged memory allocated for root, rem, and u.
gmp_lib.mpz_clears(root, rem, u, null);
See Also