Click or drag to resize
gmp_libmpz_sqrtrem Method
Set rop1 to the truncated integer part of the square root of op, like mpz_sqrt. Set rop2 to the remainder op - rop1 * rop1, which will be zero if op is a perfect square.

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_sqrtrem(
	mpz_t rop1,
	mpz_t rop2,
	mpz_t op
)

Parameters

rop1
Type: Math.Gmp.Nativempz_t
The result square root integer.
rop2
Type: Math.Gmp.Nativempz_t
The result remainder integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Examples
// Create, initialize, and set the value of op to 10000.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_si(op, 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);

// Set root = trunc(sqrt(op)), and rem = op - root.
gmp_lib.mpz_sqrtrem(root, rem, op);

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

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