Next: Projection & Decomposing, Previous: String and Stream Input and Output, Up: Complex Functions [Index]

### 5.5 Comparison Functions

Function: int mpc_cmp (mpc_t op1, mpc_t op2)
Function: int mpc_cmp_si_si (mpc_t op1, long int op2r, long int op2i)
Macro: int mpc_cmp_si (mpc_t op1, long int op2)

  Compare op1 and op2, where in the case of `mpc_cmp_si_si`, op2 is taken to be op2r + i op2i. The return value c can be decomposed into `x = MPC_INEX_RE(c)` and `y = MPC_INEX_IM(c)`, such that x is positive if the real part of op1 is greater than that of op2, zero if both real parts are equal, and negative if the real part of op1 is less than that of op2, and likewise for y. Both op1 and op2 are considered to their full own precision, which may differ. It is not allowed that one of the operands has a NaN (Not-a-Number) part.

  The storage of the return value is such that equality can be simply checked with `mpc_cmp (op1, op2) == 0`.

Function: int mpc_cmp_abs (mpc_t op1, mpc_t op2)

  Compare the absolute values of op1 and op2. The return value is 0 if both are the same (including infinity), positive if the absolute value of op1 is greater than that of op2, and negative if it is smaller. If op1 or op2 has a real or imaginary part which is NaN, the function behaves like `mpfr_cmp` on two real numbers of which at least one is NaN.