不同系统会有不同差异:
类型 | 位(byte) | 范围 |
char | 1 | -128—127 or 0 – 255 |
unsigned char | 1 | 0 – 255 |
signed int | 1 | -128—127 |
int | 4 | -2^31 – 2^32-1 |
unsigned int | 4 | 0 – 2^32 |
signed int | 4 | -2^31 – 2^32-1 |
short int | 2 | 2^15 – 2^15-1 |
unsigned short int | 2 | 0 – 2^16 |
signed short int | 2 | 2^15 – 2^15-1 |
long int | 8 | -2^63 – 2^63-1 |
signed long int | 8 | -2^63 – 2^63-1 |
unsigned long int | 8 | 0 – 2^64 |
float | 4 | +/- 3.4e +/-38(~7个数字) |
double | 8 | +/-1.7e +/- 308(~15个数字) |
long double | 16 | +/-1.7e +/- 208(~15个数字) |
浮点数float和double两种数据类型和其他数据类型存储方式不同