Converting float or negative integer to hexadecimal in Borland Delphi

前端 未结 4 2127
南旧
南旧 2021-01-23 22:51

Ive written a program that communicate with some hardware using a serial connection. It sends a lot of hexadecimal values my way (sensor readings) and every once in a while it s

4条回答
  •  既然无缘
    2021-01-23 22:56

    I've never seen a float represented in hex, so you'd have to figure out exactly what format the device is using for that. For the negative number case, you'll need to use HexToInt to covert it to an integer, and then determine if that integer is larger than whatever threshold value represents MaxInt for the hardware's integer data type. If it's bigger than that, it's a negative number, which means you'll need to, IIRC, get the number's 1s complement and convert it to negative.

提交回复
热议问题