如何存储负数

len = sprintf( mCmdParam.ByteWrite.mByteBuffer, "%02d,%02d-%02d-%02d %02d:%02d,%u,%u,%u,%u,%u,%u,%u,%u,%u\xd\xa", (UINT16)sbno, (UINT16)((0x07&curtime[6]>>4)*10 + (0x0f&curtime[6])), (UINT16)((0x07&curtime[4]>>4)*10 + (0x0f&curtime[4])), (UINT16)((0x07&curtime[3]>>4)*10 + (0x0f&curtime[3])), (UINT16)((0x07&curtime[2]>>4)*10 + (0x0f&curtime[2])), (UINT16)((0x07&curtime[1]>>4)*10 + (0x0f&curtime[1])), (UINT16)ia, (UINT16)ib, (UINT16)ic, (UINT16)ua, (UINT16)ub, (UINT16)uc, (UINT16)pft, (UINT32)pt, (UINT32)qt); /* 将二制制数据格式为一行字符串 */

这句应该如何修改/?

(UINT32)pt pt这个值是负谁.如何存到文本文件中.


比如就是-2786,如果存,看到数据中都是定义无付号数字.


实际在存储的时候,你应该是存储负数的补码


我就是存储的补码.(long)pt 存储后.为65535,还是不对啊.能否举个例子.


只有登录才能回复,可以选择微信账号登录