Click or drag to resize
gmp_libmpq_cmp_z Method
Compare op1 and op2.

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 int mpq_cmp_z(
	mpq_t op1,
	mpz_t op2
)

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: Math.Gmp.Nativempz_t
The second operand rational.

Return Value

Type: Int32
Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.
Remarks

To determine if two rationals are equal, mpq_equal is faster than mpq_cmp.

Examples
// Create, initialize, and set the value of op1 to 1 / 2.
mpq_t op1 = new mpq_t();
gmp_lib.mpq_init(op1);
gmp_lib.mpq_set_si(op1, 1, 2U);

// Create, initialize, and set the value of op2 to 3.
mpz_t op2 = new mpz_t();
gmp_lib.mpz_init(op2);
gmp_lib.mpz_set_si(op2, 3);

// Assert that op1 < op2.
Assert.IsTrue(gmp_lib.mpq_cmp_z(op1, op2) < 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clear(op1);
gmp_lib.mpz_clear(op2);
See Also