我有这个变量
unsigned long long latitude = 29.47667;
当我将此值转换为这样的数组时
ar[7] = (uint8_t)((latitude >> 56) & 0xFF);
ar[6] = (uint8_t)((latitude >> 48) & 0xFF);
ar[5] = (uint8_t)((latitude >> 40) & 0xFF);
ar[4] = (uint8_t)((latitude >> 32) & 0xFF);
ar[3] = (uint8_t)((latitude >> 24) & 0xFF);
ar[2] = (uint8_t)((latitude >> 16) & 0xFF);
ar[1] = (uint8_t)((latitude >> 8) & 0xFF);
ar[0] = (uint8_t)(latitude & 0xFF);
然后使用 tcp 套接字将其发送到服务器。当我发送时,我以十六进制打印值,然后我得到0x1d
所有零。
如何在将 unsigned long long 转换为 int 时将确切值发送到服务器。