Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!convex!grogers From: grogers@convex.com (Geoffrey Rogers) Newsgroups: comp.lang.c Subject: Re: How come << falls through at 16 on a 32-bit integer? Message-ID: <1991Apr13.143844.12533@convex.com> Date: 13 Apr 91 14:38:44 GMT References: <11004@uwm.edu> Sender: newsadm@convex.com (news access account) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 19 Nntp-Posting-Host: mozart.convex.com In article <11004@uwm.edu> markh@csd4.csd.uwm.edu (Mark William Hopkins) writes: >* #include >* main() { >* unsigned long M = 34; >* printf("%08x\n", M << 16); >* } No. The problem is the %08x expects an int and you are printing a long (unsigned long). You must also use the l flag to tell printf that the argument is a long. Try: printf("%08lx\n", M << 16) +------------------------------------+---------------------------------+ | Geoffrey C. Rogers | "Whose brain did you get?" | | grogers@convex.com | "Abbie Normal!" | | {sun,uunet,uiucdcs}!convex!grogers | | +------------------------------------+---------------------------------+