question about shift operator
Stephen J. Friedl
friedl at vsi.COM
Thu Nov 3 15:03:02 AEST 1988
In article <786 at gtx.com>, randy at gtx.com (Randy D. Miller) 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?
3.3.7 Bitwise shift operators.
Syntax:
shift_expression:
additive_expression
shift_expression << additive_expression
shift_expression >> additive_expression
Constraints:
Each of the operands shall have integral type.
Semantics:
The integral promotions are performed on each operand.
If the value of the right operand is negative or is
greater than or equal to the width in bits of the promoted
left operand, the behavior is undefined.
--
Steve Friedl V-Systems, Inc. +1 714 545 6442 3B2-kind-of-guy
friedl at vsi.com {backbones}!vsi.com!friedl attmail!vsi!friedl
----Nancy Reagan on 120MB SCSI cartridge tape: "Just say *now*"----
More information about the Comp.lang.c
mailing list