question about shift operator
Brian Matthews
blm at cxsea.UUCP
Thu Nov 3 07:11:57 AEST 1988
Randy D. Miller (randy at gtx.UUCP) writes:
|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;
|K&R 1st ed. seems to indicate the operation is undefined, but does
|the proposed standard change this?
>From section 3.3.7 "Bitwise shift operators" of the ANSI draft standard,
in the first paragraph under Semantics:
"...If the value of the right operand is negative or greater than or
equal to the width in bits of the promoted left operand, the behavior is
undefined."
--
Brian L. Matthews blm at cxsea.UUCP ...{mnetor,uw-beaver!ssc-vax}!cxsea!blm
+1 206 251 6811 Computer X Inc. - a division of Motorola New Enterprises
More information about the Comp.lang.c
mailing list