C++数值范围

C++各数据类型的取值范围

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include<iostream>
#include<string>
#include <limits>
using namespace std;
int main()
{
cout << "type: \t\t" << "************size**************"<< endl;
cout << "bool: \t\t" << "所占字节数:" << sizeof(bool);
cout << "\t最大值:" << (numeric_limits<bool>::max)();
cout << "\t\t最小值:" << (numeric_limits<bool>::min)() << endl;
cout << "char: \t\t" << "所占字节数:" << sizeof(char);
cout << "\t最大值:" << (int)(numeric_limits<char>::max)();
cout << "\t\t最小值:" <<(int) (numeric_limits<char>::min)() << endl;
cout << "signed char: \t" << "所占字节数:" << sizeof(signed char);
cout << "\t最大值:" << (int)(numeric_limits<signed char>::max)();
cout << "\t\t最小值:" << (int)(numeric_limits<signed char>::min)() << endl;
cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);
cout << "\t最大值:" << (int)(numeric_limits<unsigned char>::max)();
cout << "\t\t最小值:" << (int)(numeric_limits<unsigned char>::min)() << endl;
cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t);
cout << "\t最大值:" << (numeric_limits<wchar_t>::max)();
cout << "\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl;
cout << "short: \t\t" << "所占字节数:" << sizeof(short);
cout << "\t最大值:" << (numeric_limits<short>::max)();
cout << "\t\t最小值:" << (numeric_limits<short>::min)() << endl;
cout << "int: \t\t" << "所占字节数:" << sizeof(int);
cout << "\t最大值:" << (numeric_limits<int>::max)();
cout << "\t最小值:" << (numeric_limits<int>::min)() << endl;
cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned);
cout << "\t最大值:" << (numeric_limits<unsigned>::max)();
cout << "\t最小值:" << (numeric_limits<unsigned>::min)() << endl;
cout << "long: \t\t" << "所占字节数:" << sizeof(long);
cout << "\t最大值:" << (numeric_limits<long>::max)();
cout << "\t最小值:" << (numeric_limits<long>::min)() << endl;
cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);
cout << "\t最大值:" << (numeric_limits<unsigned long>::max)();
cout << "\t最小值:" << (numeric_limits<unsigned long>::min)() << endl;
cout << "unsigned long long: \t" << "所占字节数:" << sizeof(unsigned long long);
cout << "\t最大值:" << (numeric_limits<unsigned long long>::max)();
cout << "\t最小值:" << (numeric_limits<unsigned long long>::min)() << endl;
cout << "double: \t" << "所占字节数:" << sizeof(double);
cout << "\t最大值:" << (numeric_limits<double>::max)();
cout << "\t最小值:" << (numeric_limits<double>::min)() << endl;
cout << "long double: \t" << "所占字节数:" << sizeof(long double);
cout << "\t最大值:" << (numeric_limits<long double>::max)();
cout << "\t最小值:" << (numeric_limits<long double>::min)() << endl;
cout << "float: \t\t" << "所占字节数:" << sizeof(float);
cout << "\t最大值:" << (numeric_limits<float>::max)();
cout << "\t最小值:" << (numeric_limits<float>::min)() << endl;
cout << "size_t: \t" << "所占字节数:" << sizeof(size_t);
cout << "\t最大值:" << (numeric_limits<size_t>::max)();
cout << "\t最小值:" << (numeric_limits<size_t>::min)() << endl;
cout << "string: \t" << "所占字节数:" << sizeof(string) << endl;
// << "\t最大值:" << (numeric_limits<string>::max)() << "\t最小值:" << (numeric_limits<string>::min)() << endl;
cout << "type: \t\t" << "************size**************"<< endl;
return 0;
}
type: ************size**************
bool: 所占字节数:1 最大值:1 最小值:0
char: 所占字节数:1 最大值:127 最小值:-128
signed char: 所占字节数:1 最大值:127 最小值:-128
unsigned char: 所占字节数:1 最大值:255 最小值:0
wchar_t: 所占字节数:2 最大值:65535 最小值:0
short: 所占字节数:2 最大值:32767 最小值:-32768
int: 所占字节数:4 最大值:2147483647 最小值:-2147483648
unsigned: 所占字节数:4 最大值:4294967295 最小值:0
long: 所占字节数:4 最大值:2147483647 最小值:-2147483648
unsigned long: 所占字节数:4 最大值:4294967295 最小值:0
unsigned long long: 所占字节数:8 最大值:18446744073709551615 最小值:0
double: 所占字节数:8 最大值:1.79769e+308 最小值:2.22507e-308
long double: 所占字节数:16 最大值:1.18973e+4932 最小值:3.3621e-4932
float: 所占字节数:4 最大值:3.40282e+038 最小值:1.17549e-038
size_t: 所占字节数:8 最大值:18446744073709551615 最小值:0
string: 所占字节数:8
type: ************size**************

$$f(x)=x^{x^x}$$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<stdio.h>
#include<string.h>
int main()
{
char c, s[20], *p;
int a=1234, *i;
float f=3.141592653589;
double x=0.12345678987654321;
p="How do you do";
strcpy(s, "Hello, Comrade");
*i=12;
c='\x41';
printf("a=%d\n", a); /*结果输出十进制整数a=1234*/
printf("a=%6d\n", a); /*结果输出6位十进制数a= 1234*/
printf("a=%06d\n", a); /*结果输出6位十进制数a=001234*/
printf("a=%2d\n", a); /*a超过2位, 按实际值输出a=1234*/
printf("*i=%4d\n", *i); /*输出4位十进制整数*i= 12*/
printf("*i=%-4d\n", *i); /*输出左对齐4位十进制整数*i=12*/
printf("i=%p\n", i); /*输出地址i=06E4*/
printf("f=%f\n", f); /*输出浮点数f=3.141593*/
printf("f=6.4f\n", f); /*输出6位其中小数点后4位的浮点数
f=3.1416*/
printf("x=%lf\n", x); /*输出长浮点数x=0.123457*/
printf("x=%18.16lf\n", x);/*输出18位其中小数点后16位的长浮点
数x=0.1234567898765432*/
printf("c=%c\n", c); /*输出字符c=A*/
printf("c=%x\n", c); /*输出字符的ASCII码值c=41*/
printf("s[]=%s\n", s); /*输出数组字符串s[]=Hello, Comrade*/
printf("s[]=%6.9s\n", s);/*输出最多9个字符的字符串s[]=Hello,
Co*/
printf("s=%p\n", s); /*输出数组字符串首字符地址s=FFBE*/
printf("*p=%s\n", p); /* 输出指针字符串p=How do you do*/
printf("p=%p\n", p); /*输出指针的值p=0194*/
getch();
retunr 0; //DA8A42849788
}

MAKEFILE

MakeFile写法

Effective C++

Effective C++四十条规则

C++对象模型

深入探索C++对象模型

进程通信

进程通信

Linux多线程

Linux多线程

-------------本文结束 感谢您的阅读-------------
作者GonewithGt
有问题请 留言 或者私信我的 微博
满分是10分的话,这篇文章你给几分