typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
| 名称 | 字节长度 | 取值范围 |
|---|---|---|
| bool | 1 | false,true |
| char | 1 | -128~127 |
| signed char | 1 | -128~127 |
| unsigned char | 1 | 0~255 |
| short(signed short) | 2 | -215 ~ 215 - 1 |
| unsigned short | 2 | 0~216-1 |
| int (signed int) | 4 | -231 ~ 231-1 |
| unsigned int | 4 | 0~232-1 |
| long (signed long) | 4 | -231 ~ 231-1 |
| long long | 8 | -263 ~ 263-1 |
| unsigned long | 4 | 0~232-1 |
| float | 4 | -3.4* 10-38~ 3.4*1038 |
| double | 8 | -1.710-308 ~ 1.710-308 |
注意,uint8_t实际上就是一个char,所以输出 uint8_t类型的变量实际上输出对应的字符,而不是数值,比如:
uint8_t num=67;
cout << num << endl; //输出结果为C
reference
https://blog.csdn.net/qq_19784349/article/details/82927169