I need to extract two integer values from a byte stored within a ByteBuffer (little endian order)
ByteBuffer bb = ByteBuffer.wrap(inputBuffer);
bb.order(ByteOrder.LITTLE_ENDIAN);
The values I need to obtain from any byte within the ByteBuffer are:
length = integer value of low order nibble
frequency = integer value of high order nibble
At the moment I'm extracting the low order nybble with this code:
length = bb.getInt(index) & 0xf;
Which seems to work perfectly well. It is however the high order nybble that I seem to be having trouble interpreting correctly.
I get a bit confused with bit shifting or masking, which I think I need to perform, and any advice would be super helpful.
Thanks muchly!!