I'm currently working on a temperature measurement program, and the temperature is sent in hexadecimal from the instrument. However, when I look at the protocol, I see that negative values are calculated using two's complement, so I would like to convert the hexadecimal data to binary, and then convert it to decimal if the most significant bit is 0, and calculate two's complement if it is 1.
How can I compare whether the most significant bit is 0 or 1?
If anyone knows, please let me know.
Translated with www.DeepL.com/Translator (free version)