解决方法
位移仅在无符号类型上定义,对于被实现定义的签名类型.
这是一个有用的改进.
这是一个有用的改进.
Strictly speaking,it is defined for
signed types whenever the value is
positive and the result does not
overflow,and right shift is
implementation-defined for negative
values. Left shift,on the other hand,
is undefined for negative values
┌───┬──────────────┬──────────────────────────────────┬────────────────────────┐ │ │ Unsigned │ Signed,positive │ Signed,negative │ ├───┼──────────────┼──────────────────────────────────┼────────────────────────┤ │<< │ well-defined │ well-defined,except on overflow │ undefined behavIoUr │ │>> │ well-defined │ well-defined │ implementation-defined │ └───┴──────────────┴──────────────────────────────────┴────────────────────────┘