Merge pull request #578 from PX4/fix_mp_prime_strong_lucas_lefridge_compilation
[libtommath.git] / mp_cmp.c
blob9f3847b848286bdb696dcb4988e7e615a6ad3ecb
1 #include "tommath_private.h"
2 #ifdef MP_CMP_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* compare two ints (signed)*/
7 mp_ord mp_cmp(const mp_int *a, const mp_int *b)
9 /* compare based on sign */
10 if (a->sign != b->sign) {
11 return mp_isneg(a) ? MP_LT : MP_GT;
14 /* if negative compare opposite direction */
15 if (mp_isneg(a)) {
16 MP_EXCH(const mp_int *, a, b);
19 return mp_cmp_mag(a, b);
21 #endif