Can anyone explain the reason behind the situation below :

the following code :

#include <stdio.h>

void main()

{

unsigned int x,y;

x = 0xAAAAAAAA;

y = x >> 32;

printf("%X",y)

}

Produces:

AAAAAAAA

Why is it that if I shift a 32 bit variable by 32 bits, I get the same number. If I shift a number, say :

y = 0xFFFFFFFF >> 32

then y=0. ????

if I let x=FFFFFFFF and then do:

y = X >> 31;

y = y >> 1;

THEN I get y=0, but not if I do all the shifting at once.

Any help??????

the following code :

#include <stdio.h>

void main()

{

unsigned int x,y;

x = 0xAAAAAAAA;

y = x >> 32;

printf("%X",y)

}

Produces:

AAAAAAAA

Why is it that if I shift a 32 bit variable by 32 bits, I get the same number. If I shift a number, say :

y = 0xFFFFFFFF >> 32

then y=0. ????

if I let x=FFFFFFFF and then do:

y = X >> 31;

y = y >> 1;

THEN I get y=0, but not if I do all the shifting at once.

Any help??????

I hope this helps.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.