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 2 byte value. This code does the job just fine but prior to testing i had it written like this
int b1 = 0xffff & (content[12]<<8 | content[11]);
and the result was not right. My question is why is 0xff necessary in this scenario?