crookie wrote:
if I have the foolowing code,
main()
{
unsigned int i=34;
i>>=32;
}
why does the value of i remain 34? I thought it should be a zero.
(the g++ compiler gives me a warning about shifting >= size of variable.)
The standard [5.8/1] says about the shift operators:
[...] The behavior is undefined if the right operand is negative, or
greater than or equal to the length in bits of the promoted left operand.
It would appear that on your platform sizeof(int)<=32, whence you have
undefined behavior: anything could happen.
Best
Kai-Uwe Bux