posted 23 years ago
HI,

The left-most bit is the sign bit. If the left most bit is 1 then the number is negative else the number is positive.

This left-most bit is the most significant bit.

The right-most bit is the least significant bit.

An un-signed operator >>> means that the most significant bit is always to be filled by 0's.

if you start with a negative binary number...

1111 1010 // and you want to know the value

1. Flip the bits

0000 0101

2. Add 1

0000 0101

+

0000 0001

------------

0000 0110 // this is 6, so the value was -6.

Another shortcut:

start from the rightmost bit(least significant bit).

Just copy everything until you see first "1".Then flip the remaining bits.

The same eg:1111 1010

result:0000 0110

For more examples on shifting refer to RHE book.It has real good examples.

------------------

Cheers,

Deepa