signed short to byte in c++
问题 I'm trying to convert a HEX number into a short (2 Bytes) using C++ everything is OK except for one thing... signed conversion from short to Byte (last test) i found this question and couldn't really benefit from it: portable signed/unsigned byte cast,C++ here are my tests: // test 1 - positive B2Short (success) byte *b = new byte[2]; b[0] = 0x10; //low byte b[1] = 0x00; //heigh byte signed short test = 0; test = ByteToShort(b); cout << test << endl; // test 2 - negative B2Short (success) b[0