Beginning C question.
Stephen B Coy
coy at ssc-vax.UUCP
Thu Jul 26 04:19:18 AEST 1990
In article <7703 at uudell.dell.com>, jrh at 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 at mustang.dell.com
> Austin, TX 78759-7299
Stephen Coy
uw-beaver!ssc-vax!coy
More information about the Comp.lang.c
mailing list