Right shift and signed integer

前端 未结 5 1173
情话喂你
情话喂你 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:18

    AFAIK integers may be represented as sign-magnitude in c++, in which case sign extension would fill with 0s. So you can't rely on this.

提交回复
热议问题