c语言limits.h_ (limits.h)C ++中(整数类型的大小)的宏常量
c語言limits.h
C ++宏常量(整數類型的大小) (C++ Macro constants of (sizes of integral types))
In this tutorial, we are learning about some of the defined macro constants which are used to find the sizes of the integral types like a character, short, integer, long integer, long long integer. These macro constants are used to find the minimum and maximum size of any integral type of data type.
在本教程中,我們將學習一些定義的宏常量 ,這些常量用于查找整數類型的大小,例如字符,短整數,長整數,長整數。 這些宏常量用于查找任何整數類型的數據類型的最小和最大大小。
These macros are defined in <limits.h> header file and <climits> header (for C++ 11).
這些宏在<limits.h>頭文件和<climits>頭文件中定義(對于C ++ 11)。
C ++中的宏常量列表 (List of Macro constants in C++)
Here, is the list of the macro constants that can be used to find the sizes, minimum and maximum values of the specific integral data types.
此處是宏常量列表,可用于查找特定整數數據類型的大小,最小值和最大值 。
#myInput{width:100%;font-size:16px;padding:12px 20px 12px 40px;border:1px solid #ddd;margin-bottom:12px}#myTable{border-collapse:collapse;width:100%;border:1px solid #ddd;font-size:18px}#myTable td,#myTable th{text-align:left;padding:2px}#myTable tr{border-bottom:1px solid #ddd}#myTable tr.header,#myTable tr:hover{background-color:#f1f1f1}#myTable a,#myTable a:visited{color:#00f;text-decoration:none}#myTable a:hover{text-decoration:underline} #myInput{width:100%;font-size:16px;padding:12px 20px 12px 40px;border:1px solid #ddd;margin-bottom:12px}#myTable{border-collapse:collapse;width:100%;border:1px solid #ddd;font-size:18px}#myTable td,#myTable th{text-align:left;padding:2px}#myTable tr{border-bottom:1px solid #ddd}#myTable tr.header,#myTable tr:hover{background-color:#f1f1f1}#myTable a,#myTable a:visited{color:#00f;text-decoration:none}#myTable a:hover{text-decoration:underline}| CHAR_BIT | It returns the number of its in a char object. | 8 |
| SCHAR_MIN | It returns the minimum value of a signed char object. | -128 |
| SCHAR_MAX | It returns the maximum value of a signed char object. | 127 |
| UCHAR_MAX | It returns the maximum value of an unsigned char object. | 255 |
| CHAR_MIN | It returns the minimum value of a char object. | 0 or SCHAR_MIN |
| CHAR_MAX | It returns the maximum value of a char object | SCHAR_MAX or UCHAR_MAX |
| MB_LEN_MAX | It returns the maximum number of bytes in a multibyte character, for any locale | 1 or greater |
| SHRT_MIN | It returns the minimum value of a signed short int object. | -32768 |
| SHRT_MAX | It returns the maximum value of a signed short int object. | 32767 |
| USHRT_MAX | It returns the maximum value of an unsigned short int object. | 65535 |
| INT_MIN | It returns the minimum value of a signed int object. | -32768 or -2147483648 |
| INT_MAX | It returns the maximum value of a signed int object. | 32767 or 2147483647 |
| UINT_MAX | It returns the maximum value of an unsigned int object. | 65535 or 4294967295 |
| LONG_MIN | It returns the minimum value of a signed long int object. | -2147483648 or -9223372036854775808 |
| LONG_MAX | It returns the maximum value of a signed long int object. | 2147483647 or 9223372036854775807 |
| ULONG_MAX | It returns the maximum value of an unsigned long int object. | 4294967295 or 18446744073709551615 |
| LLONG_MIN | It returns the minimum value of a signed long long int object. | -9223372036854775808 |
| LLONG_MAX | It returns the maximum value of a signed long long int object. | 9223372036854775807 |
| ULLONG_MAX | It returns the maximum value of an unsigned long long int object. | 18446744073709551615 |
| CHAR_BIT | 它在char對象中返回其編號。 | 8 |
| SCHAR_MIN | 它返回簽名的char對象的最小值。 | -128 |
| SCHAR_MAX | 它返回已簽名char對象的最大值。 | 127 |
| UCHAR_MAX | 它返回一個無符號char對象的最大值。 | 255 |
| CHAR_MIN | 它返回一個char對象的最小值。 | 0或SCHAR_MIN |
| CHAR_MAX | 它返回一個char對象的最大值 | SCHAR_MAX或UCHAR_MAX |
| MB_LEN_MAX | 對于任何語言環境,它將返回多字節字符中的最大字節數 | 1或更大 |
| SHRT_MIN | 它返回帶符號的short int對象的最小值。 | -32768 |
| SHRT_MAX | 它返回一個有符號的short int對象的最大值。 | 32767 |
| USHRT_MAX | 它返回一個無符號short int對象的最大值。 | 65535 |
| INT_MIN | 它返回一個有符號的int對象的最小值。 | -32768或-2147483648 |
| INT_MAX | 它返回一個有符號的int對象的最大值。 | 32767或2147483647 |
| UINT_MAX | 它返回一個無符號int對象的最大值。 | 65535或4294967295 |
| LONG_MIN | 它返回一個有符號的long int對象的最小值。 | -2147483648或-9223372036854775808 |
| LONG_MAX | 它返回一個有符號的long int對象的最大值。 | 2147483647或9223372036854775807 |
| ULONG_MAX | 它返回一個無符號long int對象的最大值。 | 4294967295或18446744073709551615 |
| LLONG_MIN | 它返回一個有符號long long int對象的最小值。 | -9223372036854775808 |
| LLONG_MAX | 它返回一個有符號long long int對象的最大值。 | 9223372036854775807 |
| ULLONG_MAX | 它返回一個無符號long long int對象的最大值。 | 18446744073709551615 |
* The actual value depends on the compiler architecture or library implementation.
*實際值取決于編譯器體系結構或庫的實現。
Reference: C++ <climits> (limits.h)
參考: C ++ <climits>(limits.h)
C ++程序打印整數類型的大小 (C++ program to print the size of integral types)
// C++ program to print the size of integral types #include<iostream> #include<climits> using namespace std;int main() {cout << "CHAR_BIT " << CHAR_BIT << endl;cout << "SCHAR_MIN " << SCHAR_MIN << endl;cout << "SCHAR_MAX " << SCHAR_MAX << endl;cout << "UCHAR_MAX " << UCHAR_MAX << endl;cout << "CHAR_MIN " << CHAR_MIN << endl;cout << "CHAR_MAX " << CHAR_MAX << endl;cout << "MB_LEN_MAX " << MB_LEN_MAX << endl;cout << "SHRT_MIN " << SHRT_MIN << endl;cout << "SHRT_MAX " << SHRT_MAX << endl;cout << "USHRT_MAX " << USHRT_MAX << endl;cout << "INT_MIN " << INT_MIN << endl;cout << "INT_MAX " << INT_MAX << endl;cout << "UINT_MAX " << UINT_MAX << endl;cout << "LONG_MIN " << LONG_MIN << endl;cout << "LONG_MAX " << LONG_MAX << endl;cout << "ULONG_MAX " << ULONG_MAX << endl;cout << "LLONG_MIN " << LLONG_MIN << endl;cout << "LLONG_MAX " << LLONG_MAX << endl;cout << "ULLONG_MAX " << ULLONG_MAX << endl;return 0; }Output
輸出量
CHAR_BIT 8 SCHAR_MIN -128 SCHAR_MAX 127 UCHAR_MAX 255 CHAR_MIN -128 CHAR_MAX 127 MB_LEN_MAX 16 SHRT_MIN -32768 SHRT_MAX 32767 USHRT_MAX 65535 INT_MIN -2147483648 INT_MAX 2147483647 UINT_MAX 4294967295 LONG_MIN -9223372036854775808 LONG_MAX 9223372036854775807 ULONG_MAX 18446744073709551615 LLONG_MIN -9223372036854775808 LLONG_MAX 9223372036854775807 ULLONG_MAX 18446744073709551615翻譯自: https://www.includehelp.com/cpp-tutorial/macro-constants-of-sizes-of-integral-types.aspx
c語言limits.h
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的c语言limits.h_ (limits.h)C ++中(整数类型的大小)的宏常量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ stl stack_C ++ S
- 下一篇: MySQL 中日志的面试题总结