Arithmetic bit-shift on a signed integer

前端 未结 6 1371
别跟我提以往
别跟我提以往 2020-11-22 07:36

I am trying to figure out how exactly arithmetic bit-shift operators work in C, and how it will affect signed 32-bit integers.

To make things simple, let\'s say we w

6条回答
  •  无人及你
    2020-11-22 07:42

    In the 32 bit compiler

    x = x >> 31;

    here x is the signed integer so 32nd bit is sign bit.

    final x value is 100000...000. and 32nd bit indicate -ive value.

    here x value implement to 1's compliment.

    then final x is -32768

提交回复
热议问题