hello again P intelli,
(-1>>>1) 2147483647
(-1>>31) 1
(-1>>>32) -1
(-1>>>33) 2147483647
Do the above results follow any logic??
OK, bert will be impressed here. Bert, I loved your answer, I had a good chuckle to myself!!
>> shifts bits but uses the signed bit, most left bit if a 1 keep all shifted bits a 1, if a 0 keep all shifted bits a 0.
>>> shift the bits to the right but make all the added bits a 0, no matter what you had.
1: -1 looks like this in bits
11111111 11111111 11111111 11111111 >>> 1 is:
01111111 11111111 11111111 11111111 some large positive int 2147483647
2: 11111111 11111111 11111111 11111111 >> 31 signed bitshift so you get
11111111 11111111 11111111 11111111 = -1
not 1 as you have said 3: 11111111 11111111 11111111 11111111 >>> 32 so like saying >>> 0
11111111 11111111 11111111 11111111 = -1 cause you aint shifting anything
4: 11111111 11111111 11111111 11111111 >>> 33 is 32%33 = 1
so >>> 1 01111111 11111111 11111111 11111111 = very big int like 2147483647
hope this helps
Davy
[ February 27, 2004: Message edited by: Davy Kelly ]