File APIs for Java Developers Manipulate DOC, XLS, PPT, PDF and many others from your application. http://aspose.com/file-tools
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login

# Shift operator

Sridhar Srinivasan
Ranch Hand

Joined: Nov 07, 2003
Posts: 117
Hi!
How to find the value of 0xffffffff>>1 Can anybody help pl!Thanks
[ May 23, 2004: Message edited by: Barry Gaunt ]

Software_guy
meeta verma
Greenhorn

Joined: May 15, 2004
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

I agree. Here's the link: http://aspose.com/file-tools

subject: Shift operator