Handling words

So I’m reading bytes off an i2c read. The device is sending an int as a word (16-bit) how do I combine the two bytes I’m reading in squirrel back into a 16bit int?

Thanks

Depends on the endianness, eg if it’s big-endian (MSB first) then it’d be:

local value = (buffer[0] << 8) | buffer[1];

if its little-endian (LSB first) then it’d be:

local value = (buffer[1] << 8) | buffer[0];

Great many thanks