Next: , Previous: , Up: MPI library   [Contents][Index]


12.5 Comparisons

The next 2 functions are used to compare MPIs:

Function: int gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v)

Compare the multi-precision-integers number u and v, returning 0 for equality, a positive value for u > v and a negative for u < v. If both numbers are opaque values (cf. gcry_mpi_set_opaque), the comparison is done by checking the bit sizes using memcmp. If only one number is an opaque value, the opaque value is less than the other number.

Function: int gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v)

Compare the multi-precision-integers number u with the unsigned integer v, returning 0 for equality, a positive value for u > v and a negative for u < v.

Function: int gcry_mpi_is_neg (const gcry_mpi_t a)

Return 1 if a is less than zero; return 0 if zero or positive.