整型提升练习题01

时间:2023-01-18 00:50:13
#include<stdio.h>

int main() {
char a = -1;
//-1原码=10000000 00000000 00000000 00000001
//-1反码=11111111 11111111 11111111 11111110
//-1补码=11111111 11111111 11111111 11111111
//char只能存储一个字节长度:a=11111111
signed char b = -1;
//同理,b=11111111
unsigned char c = -1;
//同理,c=11111111
printf("%d %d %d", a, b, c);
//a整型提升(有符号位):11111111 11111111 11111111 11111111(补码)
//b整型提升(有符号位):11111111 11111111 11111111 11111111(补码)
//两者原码:10000000 00000000 00000000 00000001=-1
//c整型提升(无符号位):00000000 00000000 00000000 11111111(补码=反码=原码)c=255
return 0;
}