首页 > 代码库 > 整形变量最大值与最小值
整形变量最大值与最小值
limits.h
CHAR,SHRT,INT ,LLONG加_MAX后缀表示最大,加_MIN后缀表示最小,加U前缀表示无符号
UCHAR_MIN ,UCHAR_MAX
printf 格式化字串
%d //int
%u //unsigned int
%ld //long int
%lu //unsigned long int
%lld //long long int
%llu //unsigned long long int
printf("char类型变量所占空间为%d,char类型最小值为%d,char类型最大值为%d \n",sizeof(char),CHAR_MIN,CHAR_MAX);
整数变量类型 signed
类型名称 |
字节数 |
取值范围(10进制) |
取值范围(16进制) |
备注 |
char |
1 |
-128~+127 |
-0x80~+0x7F (CHAR_MIN,CHAR_MAX) |
同 signed char |
short |
2 |
-32768~+32767 |
-0x8000 ~+0x7FFF |
同 signed short |
short int |
2 |
-32768~+32767 |
-0x8000 ~+0x7FFF |
同 signed short |
int |
4 |
-2147483648~+2147483648 |
-0x80000000~+0x7FFFFFF |
同 signed int |
long int |
4 |
-2147483648~+2147483648 |
-0x80000000~+0x7FFFFFF |
同 signed int |
long long int |
8 |
-9223372036854775808~+9223372036854775807 |
-0x8000000000000000~0x7FFFFFFFFFFFFFFF |
同 signed long long |
|
|
|
|
|
char,short,int,long long int
无符号整数类型 unsigned
类型名称 |
字节数 |
取值范围(10进制) |
取值范围(16进制) |
备注 |
char |
1 |
0~256 |
0~0xFF (UCHAR_MAX) |
同 unsigned char |
short |
2 |
0~256 |
0~0xFFFF (USHRT_MAX) |
同 unsigned short |
short int |
2 |
0~65535 |
0~0xFFFF |
同 unsigned short |
int |
4 |
0~4294967295 |
0~0xFFFFFFF |
同 unsigned int |
long int |
4 |
0~4294967295 |
0~0xFFFFFFF |
同 unsigned long int |
long long int |
8 |
0~18446744073709551615 |
0~0xFFFFFFFFFFFFFFFF |
同 unsigned long long |
|
|
|
|
|
整形变量最大值与最小值