What's going on here?  I'm expecting the answer 0, but get 2.

#include <stdio.h>
int main(){
 unsigned x=1;
 printf("%u\n",(x<<33));
 /* outputs "2" on gcc 4.1.2 on x86_32 */

 /*
   [#4] The result of E1  <<  E2  is  E1  left-shifted  E2  bit
   positions; vacated bits are filled with zeros.  If E1 has an
   unsigned type, the value of the result  is E1*2^E2,  reduced
   modulo  one more than the maximum value representable in the
   result type.

   http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm
 */
 return 0;
}

Reply via email to