I have this line of code
int b1 = 0xffff & (content[12]<<8 | 0xff & content[11]);
I have a bytearray (content []) in little endian and need to recreate a value of 2 bytes. This code does a great job, but before testing, I wrote it as
int b1 = 0xffff & (content[12]<<8 | content[11]);
and the result was wrong. My question is, why is 0xff necessary in this case?
source share