J
joshc
I have a question about the following:
4. The result of E1 << E2 is E1 left-shifted E2 bit positions: vacated
bits are filled with zeros. ... If E1 has a signed type and a
nonnegative value, and E1x2^32 is representable in the result type,
then that is the resulting value; otherwise, the behavior is undefined.
I am a bit confused by this last clause- "otherwise, the behavior is
undefined." Does this mean I should not left shit a signed negative
value because undefined behavior will result? Or is the standard just
saying that nothing can be said about the value of the result of left
shifting a negative value? Am I at least guaranteed that the binary
representation of the signed negative integer will just be shifted left
'E2' bits?
Thanks.
4. The result of E1 << E2 is E1 left-shifted E2 bit positions: vacated
bits are filled with zeros. ... If E1 has a signed type and a
nonnegative value, and E1x2^32 is representable in the result type,
then that is the resulting value; otherwise, the behavior is undefined.
I am a bit confused by this last clause- "otherwise, the behavior is
undefined." Does this mean I should not left shit a signed negative
value because undefined behavior will result? Or is the standard just
saying that nothing can be said about the value of the result of left
shifting a negative value? Am I at least guaranteed that the binary
representation of the signed negative integer will just be shifted left
'E2' bits?
Thanks.