Hello all
First post here so hopefully I'm not asking for information that is already here.
I'm working on a project and I need to read in two bytes and then get some information out of them.
From the two bytes I need to find two numbers; offset and length.
The first 13 bits are the offset and the 3 (lsb) are the length.
I'm not entirely sure of the best way of finding out the offset from the 13 bits. I'm not sure if I need to store them into an int or a short as it's an odd number of bits.
I'm assuming that I need to mask off the 3 lsb and then turn the first 13 bits into an int but I'm not sure if that is correct.
From the information I've got relating to the offset; it is stored as a negative integer in 2's complement.
I need to do this in Java and any assistance anyone can provide would be greatly appreciated.
Thanks
Tony
First post here so hopefully I'm not asking for information that is already here.
I'm working on a project and I need to read in two bytes and then get some information out of them.
From the two bytes I need to find two numbers; offset and length.
The first 13 bits are the offset and the 3 (lsb) are the length.
I'm not entirely sure of the best way of finding out the offset from the 13 bits. I'm not sure if I need to store them into an int or a short as it's an odd number of bits.
I'm assuming that I need to mask off the 3 lsb and then turn the first 13 bits into an int but I'm not sure if that is correct.
From the information I've got relating to the offset; it is stored as a negative integer in 2's complement.
I need to do this in Java and any assistance anyone can provide would be greatly appreciated.
Thanks
Tony