Sridhar Srinivasan

Ranch Hand

Posts: 117

meeta verma

Greenhorn

Posts: 19

posted 13 years ago

0xffffffff = 1111 1111 1111 1111 1111 1111 1111 1111

since, the sight bit is one it represents a negative number.

Now 0xffffffff >> 1, i.e. signed right shift

0xffffffff >> 1 = 1111 1111 1111 1111 1111 1111 1111 1111 (u get same as previous) i.e. shift 1 bit to the right and add 1 as the most significant bit. We add one becoz we know that this number is negative (signed right shift of a negative num is always negative).

Now find the decimal of this negative num i.e. take 2's complement which will be 0000 0000 0000 0000 0000 0000 0000 0000 and add 1 and remember to put a negative sign.

So the result is -1

since, the sight bit is one it represents a negative number.

Now 0xffffffff >> 1, i.e. signed right shift

0xffffffff >> 1 = 1111 1111 1111 1111 1111 1111 1111 1111 (u get same as previous) i.e. shift 1 bit to the right and add 1 as the most significant bit. We add one becoz we know that this number is negative (signed right shift of a negative num is always negative).

Now find the decimal of this negative num i.e. take 2's complement which will be 0000 0000 0000 0000 0000 0000 0000 0000 and add 1 and remember to put a negative sign.

So the result is -1