I have an unsigned char array with 2 elements that represents a signed integer. How can I convert these 2 bytes into a signed integer?
Edit: The unsigne
It depend of endianness. Something for big endian :
unsigned char x[2]; short y = (x[0] << 8) | x[1]
Something for little endian :
unsigned char x[2]; short y = (x[1] << 8) | x[0]