Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!fluke!ssc-vax!coy From: coy@ssc-vax.UUCP (Stephen B Coy) Newsgroups: comp.lang.c Subject: Re: Beginning C question. Message-ID: <3459@ssc-vax.UUCP> Date: 25 Jul 90 18:19:18 GMT References: <10997@chaph.usc.edu> <7703@uudell.dell.com> Organization: Boeing Aerospace & Electronics, Seattle WA Lines: 25 In article <7703@uudell.dell.com>, jrh@mustang.dell.com (James Howard) writes: > main() > { > short a=0x20df; > short b=0x3244; > int c; > > c = (a<<16) + b; > printf("c = %x\n",c); > > exit(0); > } > > I used "short" because they're 16 bits on this machine, and int's are 32. On a 16 bit int system c must be a long and a must be cast to long in the equation otherwise the bits will be shifted off into a black hole. > James Howard Dell Computer Corp. !'s:uunet!dell!mustang!jrh > (512) 343-3480 9505 Arboretum Blvd @'s:jrh@mustang.dell.com > Austin, TX 78759-7299 Stephen Coy uw-beaver!ssc-vax!coy