Originally posted by Edwin Dalorzo:
I better show you with an example:
65535 << -28
This is equl to: 1048560
Why?
Well, let�s take the binary representation of -28 and AND it to 31, which is the bigger acceptable number for shifting.
-28: 11111111111111111111111111100100
+31: 00000000000000000000000000011111
AND: 00000000000000000000000000000100
AND = 4
So 65535 << -28 is the same that 65535 << 4
Edwin is this concept is right , I mean when we have negative operand right side we will first apply AND operation with this negative number and 31(in case of integer ) & 63(in case of long-I am gussing) and then shift the left hand number by this result .
One more thing , there was some
thread about this in that there were some concept of 5 in case on long & 4 in case of int or something like that , That was very good thread . If any body remember then please provide the link .
thanks .
[ February 02, 2005: Message edited by: rathi ji ]