Path: utzoo!utgpu!attcan!uunet!husc6!ogccse!blake!uw-beaver!mit-eddie!bbn!rochester!pt.cs.cmu.edu!cadre!pitt!darth!libove!root From: root@libove.UUCP (Jay M. Libove) Newsgroups: comp.lang.c Subject: Re: question about shift operator Message-ID: <192@libove.UUCP> Date: 4 Nov 88 18:40:13 GMT References: <786@gtx.com> Distribution: na Organization: Libove, Pittsburgh, PA, U.S.A. Lines: 41 From article <786@gtx.com>, by randy@gtx.com (Randy D. Miller): > I've seen conflicting information about the shift operator in cases > where operand2 is exactly equal to the number of bits in the object. > E.g., with a 32 bit int, what must the following do? > > int n; > n <<= 32; Boy am I confused. Looking at the above, I read it to be "shift an n-bit integer n bits left" which would presumably have the following effect: (let n=8 for simplicity) i = abcdefgh shift left one i = bcdefgh0 shift left one i = cdefgh00 ... shift left the last time i = 00000000 Now, why is there any question as to the result? (One machine test: SCO Xenix 286 v2.2.1 results 0 from int x; x=0xffff; x <<= 16; printf("%d\n",x); ) -- Jay Libove ARPA: jl42@andrew.cmu.edu or libove@cs.cmu.edu 5731 Centre Ave, Apt 3 BITnet: jl42@andrew or jl42@drycas Pittsburgh, PA 15206 UUCP: uunet!nfsun!libove!libove or (412) 362-8983 UUCP: psuvax1!pitt!darth!libove!libove