What are bitwise shift (bit-shift) operators and how do they work?

后端 未结 11 1470
生来不讨喜
生来不讨喜 2020-11-21 04:46

I\'ve been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators) ...

What I\'m wondering

11条回答
  •  不知归路
    2020-11-21 04:55

    One gotcha is that the following is implementation dependent (according to the ANSI standard):

    char x = -1;
    x >> 1;
    

    x can now be 127 (01111111) or still -1 (11111111).

    In practice, it's usually the latter.

提交回复
热议问题