SHIFT and MASK, and widen digit. One problem is that code of the form
digit << small_integer
implicitly assumes that the result fits in an int or unsigned int
(platform-dependent, but "int sized" in any case), since digit is
promoted "just" to int or unsigned via the usual integer promotions.
But if digit is typedef'ed as unsigned int, this loses information.
The cure for this is just to cast digit to twodigits first.
++basebits;
for (i = 0; i < size_a; ++i) {
- accum |= a->ob_digit[i] << accumbits;
+ accum |= (twodigits)a->ob_digit[i] << accumbits;
accumbits += SHIFT;
assert(accumbits >= basebits);
do {
z->ob_digit[i] = 0;
accum = 0;
for (i = wordshift, j = 0; j < oldsize; i++, j++) {
- accum |= a->ob_digit[j] << remshift;
+ accum |= (twodigits)a->ob_digit[j] << remshift;
z->ob_digit[i] = (digit)(accum & MASK);
accum >>= SHIFT;
}