unsigned int 0~4294967295
int 2147483648~2147483647
unsigned long 0~4294967295
long 2147483648~2147483647
long long的最大值:9223372036854775807
long long的最小值:-9223372036854775808
unsigned long long的最大值:1844674407370955161
__int64的最大值:9223372036854775807
__int64的最小值:-9223372036854775808
unsigned __int64的最大值:18446744073709551615
1 #include
2 #include
3 #include
4 using namespace std;
5
6 int main()
7 {
8 cout << "type: \t\t" << "************size**************"<< endl;
9 cout << "bool: \t\t" << "所占字节数:" << sizeof(bool);
10 cout << "\t最大值:" << (numeric_limits
11 cout << "\t\t最小值:" << (numeric_limits
12 cout << "char: \t\t" << "所占字节数:" << sizeof(char);
13 cout << "\t最大值:" << (numeric_limits
14 cout << "\t\t最小值:" << (numeric_limits
15 cout << "signed char: \t" << "所占字节数:" << sizeof(signed char);
16 cout << "\t最大值:" << (numeric_limits
17 cout << "\t\t最小值:" << (numeric_limits
18 cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);
19 cout << "\t最大值:" << (numeric_limits
20 cout << "\t\t最小值:" << (numeric_limits
21 cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t);
22 cout << "\t最大值:" << (numeric_limits
23 cout << "\t\t最小值:" << (numeric_limits
24 cout << "short: \t\t" << "所占字节数:" << sizeof(short);
25 cout << "\t最大值:" << (numeric_limits
26 cout << "\t\t最小值:" << (numeric_limits
27 cout << "int: \t\t" << "所占字节数:" << sizeof(int);
28 cout << "\t最大值:" << (numeric_limits
29 cout << "\t最小值:" << (numeric_limits
30 cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned);
31 cout << "\t最大值:" << (numeric_limits
32 cout << "\t最小值:" << (numeric_limits
33 cout << "long: \t\t" << "所占字节数:" << sizeof(long);
34 cout << "\t最大值:" << (numeric_limits
35 cout << "\t最小值:" << (numeric_limits
36 cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);
37 cout << "\t最大值:" << (numeric_limits
38 cout << "\t最小值:" << (numeric_limits
39 cout << "double: \t" << "所占字节数:" << sizeof(double);
40 cout << "\t最大值:" << (numeric_limits
41 cout << "\t最小值:" << (numeric_limits
42 cout << "long double: \t" << "所占字节数:" << sizeof(long double);
43 cout << "\t最大值:" << (numeric_limits
44 cout << "\t最小值:" << (numeric_limits
45 cout << "float: \t\t" << "所占字节数:" << sizeof(float);
46 cout << "\t最大值:" << (numeric_limits
47 cout << "\t最小值:" << (numeric_limits
48 cout << "size_t: \t" << "所占字节数:" << sizeof(size_t);
49 cout << "\t最大值:" << (numeric_limits
50 cout << "\t最小值:" << (numeric_limits
51 cout << "string: \t" << "所占字节数:" << sizeof(string) << endl;
52 // << "\t最大值:" << (numeric_limits
53 cout << "type: \t\t" << "************size**************"<< endl;
54 return 0;
55 }
一字节表示八位,即:1byte = 8 bit;
int: 4byte = 32 bit 有符号signed范围:2^31-1 ~ -2^31即:2147483647 ~ -2147483648无符号unsigned范围:2^32-1 ~ 0即:4294967295 ~ 0
long: 4 byte = 32 bit 同int型
double: 8 byte = 64 bit 范围:1.79769e+308 ~ 2.22507e-308
long double: 12 byte = 96 bit 范围: 1.18973e+4932 ~ 3.3621e-4932
float: 4 byte = 32 bit 范围: 3.40282e+038 ~ 1.17549e-038
int、unsigned、long、unsigned long 、double的数量级最大都只能表示为10亿,即它们表示十进制的位数不超过10个,即可以保存所有9位整数。而short只是能表示5位;
http://blog.csdn.net/tenlee/article/details/44997015