Hi all.
I think there may have been a mistake somewhere that propagated through this post.
The original question is:
"what is the result of the following .."
(byte)0x81 >> 2
The correct answer is 0xFFFFFFE0 (NOT 0xFFFFFF81).
You can
test it for yourself with the following little program:
Here are the steps to get this result:
0x81 (hexadecimal) is equal to 129 (decimal) which is
10000001 (binary).
So there is the byte value.
Next, before the right shift occurs, the byte is promoted to an int. Because the most significant bit in the original byte is a 1, 1's are used to fill in the upper bits of this integer. So we get this:
11111111 11111111 11111111 10000001
Now we do our right shift by 2, and we get this:
11111111 11111111 11111111 11100000
Finally, we convert the binary to hexidecimal:
1111 1111 1111 1111 1111 1111 1110 0000
F F F F F F E 0
So the answer is:
0xFFFFFFE0
Hope this helps.
Stephanie