X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/f4535c6454395e6d56ce0091a07b6d4f7d54a47f..298182ad446aaced14dea7ed0e7c968946787288:/mp-arith.c diff --git a/mp-arith.c b/mp-arith.c index 0172981..3af1447 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); @@ -357,7 +360,7 @@ mp *mp_bit##n##2c(mp *d, mp *a, mp *b) \ p_bn \ } else { /* Both negative */ \ mp *t = mp_not2c(MP_NEW, a); \ - mp *d = mp_not2c(d, b); \ + d = mp_not2c(d, b); \ d = mp_bit##abn(d, t, d); \ MP_DROP(t); \ p_abn \