int main() { unsigned char a = 200; //00000000000000000000000011001000(原反补相同) //11001000(char型-8bit) unsigned char b = 100; //00000000000000000000000001100100(原反补相同) //01100100(char型-8bit) unsigned char c = 0; c = a + b; //a和b都是char型,比int型短,需要发生整型提升,整型提升需要考虑补0(正数时)或补1(负数时) //a无符号整型,所以补0,结果为 //00000000000000000000000011001000 --a //00000000000000000000000001100100 --b //00000000000000000000000100101100 --c,(2进制时),变为%d为300 // 但是因为c为char型,所以只能8位,需要截断 //00101100----unsigned char c时,,,变为%d为44 printf("%d %d\n", a + b, c);//打印结果为300 44 return 0; }