mpfr_libmpfr_cmp_q Method |
Namespace: Math.Mpfr.Native
Both op1 and op2 are considered to their full own precision, which may differ. If one of the operands is NaN, set the erange flag and return zero.
Note: These functions may be useful to distinguish the three possible cases. If you need to distinguish two cases only, it is recommended to use the predicate functions (e.g., mpfr_equal_p for the equality) described below; they behave like the IEEE 754 comparisons, in particular when one or both arguments are NaN. But only floating-point numbers can be compared (you may need to do a conversion first).
// Create, initialize, and set a new floating-point number op1 to 512. mpfr_t op1 = new mpfr_t(); mpfr_lib.mpfr_init2(op1, 64U); Assert.IsTrue(mpfr_lib.mpfr_set_si(op1, 512, mpfr_rnd_t.MPFR_RNDN) == 0); // Create and initialize a new rational number op2. mpq_t op2 = new mpq_t(); gmp_lib.mpq_init(op2); gmp_lib.mpq_set_si(op2, 128, 1); // Assert that op1 > op2. Assert.IsTrue(mpfr_lib.mpfr_cmp_q(op1, op2) > 0); // Release unmanaged memory allocated for op1 and op2. mpfr_lib.mpfr_clear(op1); gmp_lib.mpq_clear(op2);