Right shift and signed integer

前端 未结 5 1180
情话喂你
情话喂你 2020-12-03 10:44

On my compiler, the following pseudo code (values replaced with binary):

sint32 word = (10000000 00000000 00000000 00000000);
word >>= 16;
5条回答
  •  庸人自扰
    2020-12-03 11:28

    No, you can't rely on this behaviour. Right shifting of negative quantities (which I assume your example is dealing with) is implementation defined.

提交回复
热议问题