Consider the following snip of java code
byte b=(byte) 0xf1; byte c=(byte)(b>>4); byte d=(byte) (b>>>4);
output:
<
I'd guess that b is sign extended to int before shifting.
b
int
So this might work as expected:
(byte)((0x000000FF & b)>>4)