C++中数据类型表示范围
32位机器环境下结果如下:
Type |
Size |
数值范围 |
无值型void |
0 byte |
无值域 |
布尔型bool |
1 byte |
true false |
有符号短整型short [int] /signed short [int] |
2 byte |
-32768~32767 |
无符号短整型unsigned short [int] |
2 byte |
0~65535 |
有符号整型int /signed [int] |
4 byte |
-2147483648~2147483647 |
无符号整型unsigned [int] |
4 byte |
0~4294967295 |
有符号长整型long [int]/signed long [int] |
4 byte |
-2147483648~2147483647 |
无符号长整型unsigned long [int] |
4 byte |
0~4294967295 |
long long |
8 byte |
0~18446744073709552000 |
有符号字符型char/signed char |
1 byte |
-128~127 |
无符号字符型unsigned char |
1 byte |
0~255 |
宽字符型wchar_t (unsigned short.) |
2 byte |
0~65535 |
单精度浮点型float |
4 byte |
-3.4E-38~3.4E+38 |
双精度浮点型double |
8 byte |
1.7E-308~1.7E+308 |
long double |