X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/1dda051bbae15d2f45db44e1828056b3f2e97285..4108c8d21f2dff8c2666fdeebc5a76b449e2808c:/mp-arith.c diff --git a/mp-arith.c b/mp-arith.c index 0172981..941b8df 100644 --- a/mp-arith.c +++ b/mp-arith.c @@ -229,9 +229,12 @@ int mp_eq(const mp *a, const mp *b) { return (MP_EQ(a, b)); } int mp_cmp(const mp *a, const mp *b) { - if (!((a->f ^ b->f) & MP_NEG)) - return (mpx_ucmp(a->v, a->vl, b->v, b->vl)); - else if (a->f & MP_NEG) + if (!((a->f ^ b->f) & MP_NEG)) { + if (a->f & MP_NEG) + return (-mpx_ucmp(a->v, a->vl, b->v, b->vl)); + else + return (mpx_ucmp(a->v, a->vl, b->v, b->vl)); + } else if (a->f & MP_NEG) return (-1); else return (+1);