Are the shift operators (<<, >>) arithmetic or logical in C?

后端 未结 11 1705
粉色の甜心
粉色の甜心 2020-11-22 07:52

In C, are the shift operators (<<, >>) arithmetic or logical?

11条回答
  •  感动是毒
    2020-11-22 08:43

    gcc will typically use logical shifts on unsigned variables and for left-shifts on signed variables. The arithmetic right shift is the truly important one because it will sign extend the variable.

    gcc will will use this when applicable, as other compilers are likely to do.

提交回复
热议问题