-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataTypes.cpp
More file actions
59 lines (52 loc) · 2.86 KB
/
dataTypes.cpp
File metadata and controls
59 lines (52 loc) · 2.86 KB
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
/*
dataTypes.cpp
Displays tables of usefull information on the primative data types
Andre Dallaire
20/04/2022
*/
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;
int main(){
cout << left;
cout << "C++ Datatype Reference" << endl;
cout << endl;
cout << endl;
//ints
cout << "Integers" << endl;
cout << endl;
cout << setw(22) << "Type" << setw(6) << "Size" << setw(22) << "Min" << setw(22) << "Max" << endl;
//short
cout << setw(22) << "short" << setw(6) << sizeof(short) << setw(22) << numeric_limits<short>::min() << setw(22) << numeric_limits<short>::max() << endl;
cout << setw(22) << "unsigned short" << setw(6) << sizeof(unsigned short) << setw(22) << numeric_limits<unsigned short>::min() << setw(22) << numeric_limits<unsigned short>::max() << endl;
//int
cout << setw(22) << "int" << setw(6) << sizeof(int) << setw(22) << numeric_limits<int>::min() << setw(22) << numeric_limits<int>::max() << endl;
cout << setw(22) << "unsigned int" << setw(6) << sizeof(unsigned int) << setw(22) << numeric_limits<unsigned int>::min() << setw(22) << numeric_limits<unsigned int>::max() << endl;
//long
cout << setw(22) << "long" << setw(6) << sizeof(long) << setw(22) << numeric_limits<long>::min() << setw(22) << numeric_limits<long>::max() << endl;
cout << setw(22) << "unsigned long" << setw(6) << sizeof(unsigned long) << setw(22) << numeric_limits<unsigned long>::min() << setw(22) << numeric_limits<unsigned long>::max() << endl;
//long long
cout << setw(22) << "long long" << setw(6) << sizeof(long long) << setw(22) << numeric_limits<long long>::min() << setw(22) << numeric_limits<long long>::max() << endl;
cout << setw(22) << "unsigned long long" << setw(6) << sizeof(unsigned long long) << setw(22) << numeric_limits<unsigned long long>::min() << setw(22) << numeric_limits<unsigned long long>::max() << endl;
//doubles
cout << endl;
cout << "Decimals" <<endl;
cout << endl;
cout << setw(12) << "Type" << setw(6) << "Size" << setw(10) << "Precision" << endl;;
//float
cout << setw(12) << "float" << setw(6) << sizeof(float) << setw(10) << numeric_limits<float>::digits10 << endl;
//double
cout << setw(12) << "double" << setw(6) << sizeof(double) << setw(10) << numeric_limits<double>::digits10 << endl;
//long double
cout << setw(12) << "long double" << setw(6) << sizeof(long double) << setw(10) << numeric_limits<long double>::digits10 << endl;
cout << endl;
//char and bool
cout << "Others" << endl;
cout << endl;
cout << setw(6) << "Type" << setw(6) << "Size" << endl;
cout << setw(6) << "bool" << setw(6) << sizeof(bool) << endl;
cout << setw(6) << "char" << setw(6) << sizeof(char) << endl;
cout << endl;
cout << "Note all sizes are in bytes" << endl;
}