Index: mpi-1.8.6/mpi.c =================================================================== --- mpi-1.8.6.orig/mpi.c 2012-03-04 11:49:57.142719257 -0800 +++ mpi-1.8.6/mpi.c 2012-03-04 11:49:59.676143507 -0800 @@ -764,7 +764,7 @@ if((pow = s_mp_ispow2d(d)) >= 0) { mp_digit mask; - mask = (1 << pow) - 1; + mask = ((mp_digit) 1 << pow) - 1; rem = DIGIT(a, 0) & mask; if(q) { @@ -3081,7 +3081,7 @@ return; /* Flush all the bits above 2^d in its digit */ - dmask = (1 << nbit) - 1; + dmask = ((mp_digit) 1 << nbit) - 1; dp[ndig] &= dmask; /* Flush all digits above the one with 2^d in it */ @@ -3114,7 +3114,7 @@ dp = DIGITS(mp); used = USED(mp); d %= DIGIT_BIT; - mask = (1 << d) - 1; + mask = ((mp_digit) 1 << d) - 1; /* If the shift requires another digit, make sure we've got one to work with */ @@ -3162,7 +3162,7 @@ s_mp_rshd(mp, d / DIGIT_BIT); d %= DIGIT_BIT; - mask = (1 << d) - 1; + mask = ((mp_digit) 1 << d) - 1; save = 0; for(ix = USED(mp) - 1; ix >= 0; ix--) { @@ -3842,7 +3842,7 @@ if((res = s_mp_pad(a, dig + 1)) != MP_OKAY) return res; - DIGIT(a, dig) |= (1 << bit); + DIGIT(a, dig) |= ((mp_digit) 1 << bit); return MP_OKAY;