in a file named COPYING. Among other things, the copyright
notice and this notice must be preserved on all copies. */
+#include <ansidecl.h>
#include "flonum.h"
/* plan for a . b => p(roduct)
}
carry = 0;
significant = 0;
- for (N = 0;
- N <= size_of_sum;
- N++)
+ for (N = 0; N <= size_of_sum; N++)
{
work = carry;
carry = 0;
- for (A = 0;
- A <= N;
- A++)
+ for (A = 0; A <= N; A++)
{
B = N - A;
if (A <= size_of_a && B <= size_of_b && B >= 0)
#ifdef TRACE
printf ("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work);
#endif
- work += a->low[A] * b->low[B];
+ /* Watch out for sign extension! Without the casts, on
+ the DEC Alpha, the multiplication result is *signed*
+ int, which gets sign-extended to convert to the
+ unsigned long! */
+ work += (unsigned long) a->low[A] * (unsigned long) b->low[B];
carry += work >> LITTLENUM_NUMBER_OF_BITS;
work &= LITTLENUM_MASK;
#ifdef TRACE
}
}
/*
- * [P]-> position # size_of_sum + 1.
- * This is where 'carry' should go.
- */
+ * [P]-> position # size_of_sum + 1.
+ * This is where 'carry' should go.
+ */
#ifdef TRACE
printf ("final carry =%04x\n", carry);
#endif
/* Shift right 1 to make room for most significant littlenum. */
exponent++;
P--;
- for (q = product->low + P;
- q >= product->low;
- q--)
+ for (q = product->low + P; q >= product->low; q--)
{
work = *q;
*q = carry;