The various symbolic constants are defined in the header file Climits (limits.h) in a macro definition to represent the range of various integer type representations, such as the maximum minimum value of int, the maximum minimum value of long, and so on.
Symbolic constants |
Said |
Char_bit |
The number of bits of char |
Char_max |
Maximum value of Char |
Char_min |
Minimum value of Char |
Schar_max |
Maximum value of signed Char |
Schar_min |
Signed minimum value of Char |
Uchar_max |
Maximum value of unsigned char |
Shrt_max |
The maximum value of short |
Shrt_min |
Minimum value of short |
Ushrt_max |
Unsigned the maximum value of short |
Int_max |
The maximum value of int |
Int_min |
The minimum value of int |
Unit_max |
Maximum value of unsigned int |
Long_max |
The maximum value of long |
Long_min |
The minimum value of long |
Long_max |
Unsigned the maximum value of long |
[CPP]View PlainCopy
- #include <iostream>
- #include <climits>
- Using namespace std;
- int main ()
- {
- cout << "Size:" << Endl;
- cout << "int is" << sizeof (int) << "bytes." << Endl;
- cout << "short are" << sizeof (short) << "bytes." << Endl;
- cout << "Long is" << sizeof (long) << "bytes." << Endl << Endl;
- cout << "Bits per byte =" << char_bit << endl << Endl;
- cout << "Maximum values:" << Endl;
- cout << "int:" << int_max << Endl;
- cout << "short:" << shrt_max << Endl;
- cout << "long:" << Long_max << Endl;
- cout << "char:" << char_max << Endl;
- cout << "signed char:" << schar_max << Endl;
- cout << "unsigned int:" << uint_max << Endl;
- cout << "unsigned short:" << ushrt_max << Endl;
- cout << "unsigned long:" << Ulong_max << Endl;
- cout << "unsigned char:" << uchar_max << endl << Endl;
- cout << "Minimum values:" << Endl;
- cout << "int:" << int_min << Endl;
- cout << "short:" << shrt_min << Endl;
- cout << "long:" << long_min <<endl;
- cout << "char:" << char_min <<endl;
- cout << "signed char:" << schar_min <<endl;
- System ("pause");
- return 0;
- }
Run results
The result is consistent with the subscript.
Note: The symbolic constants in the header file Climits are the range of table numbers that are known to the integer data, and cannot get the range of table numbers for floating-point type data.
<cfloat> The header file contains the system's floating-point length limit, which replaces the header file <float.h>
<climits> The header file contains the system's integer length limit, which has replaced the header file <limits.h>
Use symbolic constants in header file Climits to learn the range of table numbers for integer data---gyy finishing