尝试将对齐的数组转换uint8[8]
为double
. 使用位操作转换为特别容易,但我知道uint8[4]
就符号位而言可能会变得混乱?long
double
在Java中我只是使用ByteBuffer.wrap(bytes).getDouble()
,但我认为它在C中并不容易。
我试图实现这段代码,但最后一个命令给出了错误Expression is not assignable
并且Shift count >= width of type
long tempHigh = 0;
long tempLow = 0;
double sum = 0;
tempHigh |= buffer[0] & 0xFF;
tempHigh <<= 8;
tempHigh |= buffer[1] & 0xFF;
tempHigh <<= 8;
tempHigh |= buffer[2] & 0xFF;
tempHigh <<= 8;
tempHigh |= buffer[3] & 0xFF;
tempLow |= buffer[4] & 0xFF;
tempLow <<= 8;
tempLow |= buffer[5] & 0xFF;
tempLow <<= 8;
tempLow |= buffer[6] & 0xFF;
tempLow <<= 8;
tempLow |= buffer[7] & 0xFF;
sum |= ((tempHigh & 0xFFFF) <<= 32) + (tempLow & 0xFFFF);
如何正确完成此过程或仅解决我犯的错误?
提前致谢。