question about shift operator
Jay M. Libove
root at libove.UUCP
Sat Nov 5 04:40:13 AEST 1988
>From article <786 at gtx.com>, by randy at 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 at andrew.cmu.edu or libove at cs.cmu.edu
5731 Centre Ave, Apt 3 BITnet: jl42 at andrew or jl42 at drycas
Pittsburgh, PA 15206 UUCP: uunet!nfsun!libove!libove or
(412) 362-8983 UUCP: psuvax1!pitt!darth!libove!libove
More information about the Comp.lang.c
mailing list