* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
* Catacomb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* Catacomb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
return mp_setbit(d, x, n);
d = mp_not2c(d, x);
d = mp_clearbit(d, d, n);
return mp_setbit(d, x, n);
d = mp_not2c(d, x);
d = mp_clearbit(d, d, n);
- 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)
*/
#define MP_BIT2CBINOP(n, base, an, bn, abn, p_base, p_an, p_bn, p_abn) \
*/
#define MP_BIT2CBINOP(n, base, an, bn, abn, p_base, p_an, p_bn, p_abn) \
p_bn \
} else { /* Both negative */ \
mp *t = mp_not2c(MP_NEW, a); \
p_bn \
} else { /* Both negative */ \
mp *t = mp_not2c(MP_NEW, a); \
MPX_USUBN(d->v, d->vl, 1);
else
MPX_UADDN(d->v, d->vl, 1);
} else {
MPX_USUBN(d->v, d->vl, 1);
else
MPX_UADDN(d->v, d->vl, 1);
} else {
mpx_usub(d->v, d->vl, a->v, a->vl, &one, &one + 1);
else
mpx_uadd(d->v, d->vl, a->v, a->vl, &one, &one + 1);
mpx_usub(d->v, d->vl, a->v, a->vl, &one, &one + 1);
else
mpx_uadd(d->v, d->vl, a->v, a->vl, &one, &one + 1);
{
if (!MP_EQ(expect, result)) {
fprintf(stderr, "\n*** %s failed", op);
{
if (!MP_EQ(expect, result)) {
fprintf(stderr, "\n*** %s failed", op);
- fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10);
- fputs("\n*** b = ", stderr); mp_writefile(b, stderr, 10);
+ fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10);
+ fputs("\n*** b = ", stderr); mp_writefile(b, stderr, 10);
fputs("\n*** result = ", stderr); mp_writefile(result, stderr, 10);
fputs("\n*** expect = ", stderr); mp_writefile(expect, stderr, 10);
fputc('\n', stderr);
fputs("\n*** result = ", stderr); mp_writefile(result, stderr, 10);
fputs("\n*** expect = ", stderr); mp_writefile(expect, stderr, 10);
fputc('\n', stderr);
if (strcmp(v[0].buf, "and") == 0) op = 1;
else if (strcmp(v[0].buf, "or") == 0) op = 7;
else if (strcmp(v[0].buf, "nand") == 0) op = 14;
if (strcmp(v[0].buf, "and") == 0) op = 1;
else if (strcmp(v[0].buf, "or") == 0) op = 7;
else if (strcmp(v[0].buf, "nand") == 0) op = 14;
{ "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 } },
{ "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 } },
{ "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 } },
{ "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 } },