Fix bit operations. Test them (a bit) better.
[u/mdw/catacomb] / mp-arith.c
index a070675..759056b 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp-arith.c,v 1.14 2002/10/15 19:18:31 mdw Exp $
+ * $Id: mp-arith.c,v 1.15 2002/10/19 17:56:50 mdw Exp $
  *
  * Basic arithmetic on multiprecision integers
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp-arith.c,v $
+ * Revision 1.15  2002/10/19 17:56:50  mdw
+ * Fix bit operations.  Test them (a bit) better.
+ *
  * Revision 1.14  2002/10/15 19:18:31  mdw
  * New operation to negate numbers.
  *
@@ -318,7 +321,7 @@ mp *mp_neg(mp *d, mp *a)
                                                                        \
 mp *mp_bit##string(mp *d, mp *a, mp *b)                                        \
 {                                                                      \
-  MP_DEST(d, MAX(MP_LEN(a), MP_LEN(b)), a->f | b->f);                  \
+  MP_DEST(d, MAX(MP_LEN(a), MP_LEN(b)), (a->f | b->f) & ~MP_NEG);      \
   mpx_bit##string(d->v, d->vl, a->v, a->vl, b->v, b->vl);              \
   d->f = (a->f | b->f) & MP_BURN;                                      \
   MP_SHRINK(d);                                                                \