C++基础
类型名称 |
字节 |
其他名称 |
值的范围 |
---|---|---|---|
int |
4 |
signed |
–2,147,483,648 到 2,147,483,647 |
unsigned int |
4 |
unsigned |
0 到 4,294,967,295 |
__int8 |
1 |
char |
–128 到 127 |
unsigned __int8 |
1 |
unsigned char |
0 到 255 |
__int16 |
2 |
short、short int、signed short int |
–32,768 到 32,767 |
unsigned __int16 |
2 |
unsigned short、unsigned short int |
0 到 65,535 |
__int32 |
4 |
signed、signed int、int |
–2,147,483,648 到 2,147,483,647 |
unsigned __int32 |
4 |
unsigned、unsigned int |
0 到 4,294,967,295 |
__int64 |
8 |
long long、signed long long |
–9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 |
unsigned __int64 |
8 |
unsigned long long |
0 到 18,446,744,073,709,551,615 |
bool |
1 |
无 |
false 或 true |
char |
1 |
无 |
-128 到 127(默认) 0 到 255(当使用 /J 编译时) |
signed char |
1 |
无 |
–128 到 127 |
unsigned char |
1 |
无 |
0 到 255 |
short |
2 |
short int、signed short int |
–32,768 到 32,767 |
unsigned short |
2 |
unsigned short int |
0 到 65,535 |
long |
4 |
long int、signed long int |
–2,147,483,648 到 2,147,483,647 |
unsigned long |
4 |
unsigned long int |
0 到 4,294,967,295 |
long long |
8 |
无(与 __int64 等效) |
–9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 |
unsigned long long |
8 |
无(与无符号的 __int64 等效) |
0 到 18,446,744,073,709,551,615 |
enum |
varies |
无 |
请参阅本文后面的备注。 |
float |
4 |
无 |
3.4E +/- 38(7 位数) |
double |
8 |
无 |
1.7E +/- 308(15 位数) |
long double |
与 double 相同 |
无 |
与 double 相同 |
wchar_t |
2 |
__wchar_t |
0 到 65,535 |