X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/a69a3efddbe1261f55e90d4ff477053ab80663a5..025c5f4aa5ffbf8948482a4233318db81c2df5d2:/mp-arith.c?ds=sidebyside diff --git a/mp-arith.c b/mp-arith.c index 4bd0976..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); @@ -723,6 +726,7 @@ RIG(lsr2c, mp_lsr2c) RIG(add, mp_add) RIG(sub, mp_sub) RIG(mul, mp_mul) +RIG(exp, mp_exp) #undef RIG @@ -908,6 +912,7 @@ static test_chunk tests[] = { { "sub", tsub, { &type_mp, &type_mp, &type_mp, 0 } }, { "mul", tmul, { &type_mp, &type_mp, &type_mp, 0 } }, { "div", tdiv, { &type_mp, &type_mp, &type_mp, &type_mp, 0 } }, + { "exp", texp, { &type_mp, &type_mp, &type_mp, 0 } }, { "bin2c", tbin, { &type_string, &type_mp, &type_mp, &type_mp, 0 } }, { "odd", todd, { &type_mp, &type_uint32, &type_mp, 0 } }, { "neg", tneg, { &type_mp, &type_mp, 0 } },