Corrected the bigint_int() routine with regards to large integers (as
authorJoey Schulze <joey@infodrom.org>
Mon, 22 Aug 2005 19:36:23 +0000 (19:36 +0000)
committerJoey Schulze <joey@infodrom.org>
Mon, 22 Aug 2005 19:36:23 +0000 (19:36 +0000)
large as or larger than BIGINT_MAX) so that arithmetic actually works

bigint.c

index fe963e1..99fc7b0 100644 (file)
--- a/bigint.c
+++ b/bigint.c
@@ -57,8 +57,13 @@ bigint bigint_int(int num)
   int i;
 
   for (i=0; i<BIGINT_LEN; i++) x.val[i] = 0L;
-  x.val[0] = num;
-  x.val[1] = 0;
+  if (num < BIGINT_MAX)
+    x.val[0] = num;
+  else {
+    x.val[0] = num-BIGINT_MAX;
+    x.val[1] = num/BIGINT_MAX;
+  }
+
   return x;
 }