有人可以帮助我理解此代码正在发生什么。它看起来像是从一个数组中创建一个整数。我不知道它是如何做到这一点。为什么在OxFF上有一个按位操作&? Inst这会产生相同的结果?C位操作问题
//first take the first 4 bytes read out of the socket into an array and
//make them a 32 bit integer
long ltemp =0;
long ltemp2 = 0;
ltemp = ltemp | (unsigned char)(analog_val_ptr[0] & 0xff);
ltemp = ltemp << 24;
ltemp2 = ltemp2 | (unsigned char)(analog_val_ptr[1] & 0xff);
ltemp2 = ltemp2 << 16;
ltemp = ltemp2 | ltemp;
ltemp2 =0;
ltemp2 = ltemp2 | (unsigned char)(analog_val_ptr[2] & 0xff);
ltemp2 = ltemp2 << 8;
ltemp = ltemp2 | ltemp;
ltemp = ltemp | (unsigned char)(analog_val_ptr[3] & 0xff);
///then convert that integer into a float, passing
analog_val_ptr的类型是什么?它看起来像程序员试图通过使用'&0xFF'并转换为'unsigned char'来加倍确定。我想它们都可以自己做。 – john
它的一个字节,数据从套接字进入 – user489041