警告:当在C++中把bytestream读入double变量时,左移计数>=类型的宽度。

问题描述 投票:0回答:1

(bytes[1] << 8)

double foo;
foo = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24) | (bytes[44] << 32) | (bytes[5] << 40) | (bytes[6] << 48) | (bytes[7] << 56);

正如你所看到的,我试图用64位读取。尽管double不是一个固定的大小,但在几乎所有的机器上都应该是64位的。(sizeof(double) 给我8个字节的大小)

但我还是得到了这个警告。

警告:左移计数>=类型的宽度。

我可以忽略这个警告吗--或者我可以以某种方式使双数的大小固定下来(因为我知道在CC++中没有大小固定的浮点数据类型)?

谢谢你的帮助

c++ byte bit-shift
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.