programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Shift operator

Sridhar Srinivasan
Ranch Hand
Posts: 117
Hi!
How to find the value of 0xffffffff>>1 Can anybody help pl!Thanks
[ May 23, 2004: Message edited by: Barry Gaunt ]

meeta verma
Greenhorn
Posts: 19
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