How come << falls through at 16 on a 32-bit integer?

Lars Wirzenius wirzenius at cc.helsinki.fi
Sun Apr 14 12:25:19 AEST 1991


In article <11004 at uwm.edu>, markh at csd4.csd.uwm.edu (Mark William Hopkins) writes:
> Why am I getting 0 for output here when unsigned long's are 32 bits with the
> *    unsigned long M = 34;
> *    printf("%08x\n", M << 16);

It's because the x format specifier means the argument is of size int,
not long.  Use lx instead. 

-- 
Lars Wirzenius    wirzenius at cc.helsinki.fi



More information about the Comp.lang.c mailing list