From 858859cf6fd6becef038cf4d9c1e650c3f2a9cc6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 10 Dec 2011 20:41:06 -0800 Subject: Bignum support in mult function. * arith.c: Regenerated. * arith.txr (CNUM_BIT): New constant. (bignum, bignum_dbl_ipt): New static functions. (@{add-fname}): Use bignum function. (mul): New functions, rewrite of mul from lib.c. * lib.c (mul): Function removed. * mpi-patches/add-mp-set-intptr (mp_set_intptr): Revised patch. Local variable v should be int_ptr_t not unsigned long. Also, the mp_set interface doesn't set the sign; it's an unsigned interface. We must do that ourselves. * mpi-patches/fix-mult-bug: The main multiplication function is also broken in the same way, requiring the cast. * mpi-patches/mpi-set-double-intptr: Fixed use of wrong type for local variable v. --- lib.c | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 84d61371..1c510fd2 100644 --- a/lib.c +++ b/lib.c @@ -848,37 +848,6 @@ val minusv(val minuend, val nlist) return neg(minuend); } -val mul(val anum, val bnum) -{ - cnum a = c_num(anum); - cnum b = c_num(bnum); - -#ifdef HAVE_LONGLONG_T - if (sizeof (longlong_t) >= 2 * sizeof (cnum)) { - longlong_t product = a * b; - numeric_assert (product >= NUM_MIN && product <= NUM_MAX); - return num(product); - } else -#endif - { - if (a > 0){ - if (b > 0) { - numeric_assert (a <= (NUM_MAX / b)); - } else { - numeric_assert (b >= (NUM_MIN / a)); - } - } else { - if (b > 0) { - numeric_assert (a >= (NUM_MIN / b)); - } else { - numeric_assert ((a == 0) || (b >= (NUM_MIN / a))); - } - } - - return num(a * b); - } -} - val mulv(val nlist) { if (!nlist) -- cgit v1.2.3