Bug fix.
authormdw <mdw>
Sat, 20 Mar 2004 00:14:03 +0000 (00:14 +0000)
committermdw <mdw>
Sat, 20 Mar 2004 00:14:03 +0000 (00:14 +0000)
mp-arith.c
tests/mp

index aac408f..59198cf 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp-arith.c,v 1.16.2.1 2003/06/10 13:21:10 mdw Exp $
+ * $Id: mp-arith.c,v 1.16.2.2 2004/03/20 00:14:03 mdw Exp $
  *
  * Basic arithmetic on multiprecision integers
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp-arith.c,v $
+ * Revision 1.16.2.2  2004/03/20 00:14:03  mdw
+ * Bug fix.
+ *
  * Revision 1.16.2.1  2003/06/10 13:21:10  mdw
  * Fix bug dividing small things by large ones.
  *
@@ -622,7 +625,7 @@ void mp_div(mp **qq, mp **rr, mp *a, mp *b)
   if (r)
     MP_DROP(r);
   r = a;
-  MP_DEST(r, MP_LEN(b) + 2, a->f | b->f);
+  MP_DEST(r, MAX(MP_LEN(a), MP_LEN(b)) + 2, a->f | b->f);
 
   /* --- Fix up the quotient too --- */
 
index 1c65693..3e5757c 100644 (file)
--- a/tests/mp
+++ b/tests/mp
@@ -1,6 +1,6 @@
 # Test vectors for MP functions
 #
-# $Id: mp,v 1.15.2.1 2003/06/10 13:21:10 mdw Exp $
+# $Id: mp,v 1.15.2.2 2004/03/20 00:14:03 mdw Exp $
 
 add {
   5 4 9; 5 -4 1; -5 4 -1; -5 -4 -9;
@@ -18,9 +18,15 @@ mul {
 }
 
 div {
-#  9 4 2 1; -9 4 -3 3; 9 -4 -3 -3; -9 -4 2 -1;
+  9 4 2 1; -9 4 -3 3; 9 -4 -3 -3; -9 -4 2 -1;
   -3 6277101735386680763835789423207666416083908700390324961279
     -1 6277101735386680763835789423207666416083908700390324961276;
+  3131675836296406071791252329528905062261497366991742517193
+    1110875761630725856340142297645383444629395595869672555585
+    2 909924313034954359110967734238138173002706175252397406023;
+  3131675836296406071791252329528905062261497366991742517193
+    53
+    59088223326347284373419855274130284193613157867768726739 26;
 }
 
 bin2c {