Re: Nonzero result when left-shift greater than width of unsigned type

2007-04-13 Thread Ken Takusagawa
On 4/13/07, Marcus Meissner <[EMAIL PROTECTED]> wrote: On Fri, Apr 13, 2007 at 05:38:03AM -0400, Ken Takusagawa wrote: > What's going on here? I'm expecting the answer 0, but get 2. > > #include > int main(){ > unsigned x=1; > printf("%u\n",(x<

Nonzero result when left-shift greater than width of unsigned type

2007-04-13 Thread Ken Takusagawa
What's going on here? I'm expecting the answer 0, but get 2. #include 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 a