I'am struggling again with type conversions in java... i need to read a 5 byte value from a ByteBuffer
and store the value in a long
.
Therefore I did this:
byte msb = b.get();
int lsb = b.getInt();
System.out.println(msb + " " + lsb);
long number = ((msb << 32)) | (((long) lsb) & 0xFFFFFFFF);
System.out.println(number);
and the log gives me the following result:
1 376263385
376263385
so msb and lsb are read correctly, but if i join them together i only get the lsb value in there. I tried to bitmask the values and tried different types to read from, but that doesnt work either.