cout << (int)(unsigned short)(char)-1 << endl; 对于类型提升,在编码为补码的情形下,对有符号数,扩展存储位数的方法是对于新的高位字节,使用当前最高有效位(符号位)的值进行填充,即为符号扩展;而对于无符号数,则是对高位直接填零,即为零扩展。
(char)-1补码是1111 1111
(unsigned short)(char)-1 补码是1111 1111 1111 1111
(int)(unsigned short)(char)-1补码是0000 0000 0000 0000 1111 1111 1111 1111