按C语音标准解释啊.
见ISO-IEC9899 6.3.1
If an int can represent all values of the original type, the value is converted to an int;
otherwise, it is converted to an unsigned int. These are called the integer
promotions.48)
48) The integer promotions are applied only: as part of the usual arithmetic conversions, to certain
argument expressions, to the operands of the unary +, -, and ~ operators, and to both operands of the
shift operators, as specified by their respective subclauses.
你这个语句实际上包括'整型提升'和'整型转换'2个操作.
data=~ss;
~适用整型提升, ss提升到int类型, 之后取反, 为0XFFFFFFFC.
之后, int类型转换成unsigned int类型.最后结果是0XFFFFFFFC.
|