Click or drag to resize
gmp_libmpq_cmp 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(
	mpq_t op1,
	mpq_t op2
)

Parameters

op1
Type: Math.Gmp.Nativempq_t
The first operand rational.
op2
Type: Math.Gmp.Nativempq_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 1 / 3.
mpq_t op2 = new mpq_t();
gmp_lib.mpq_init(op2);
gmp_lib.mpq_set_si(op2, 1, 3U);

// Assert that op1 > op2.
Assert.IsTrue(gmp_lib.mpq_cmp(op1, op2) > 0);

// Release unmanaged memory allocated for op1 and op2.
gmp_lib.mpq_clears(op1, op2, null);
See Also