I need to extract two integer values ββfrom a byte stored in a ByteBuffer (small ordinal)
ByteBuffer bb = ByteBuffer.wrap(inputBuffer); bb.order(ByteOrder.LITTLE_ENDIAN);
The values ββI need to get from any byte in ByteBuffer are as follows:
length = lower order integer nibble
frequency = high order integer nibble
I am currently extracting the lower order using this code:
length = bb.getInt(index) & 0xf;
Which seems to work fine. However, as a rule, I usually have problems with interpretation.
I'm a bit confused about bit shifting or disguise, which I think I need to follow, and any advice would be very helpful.
Thanks a lot!
source share