日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言limits.h_ (limits.h)C ++中(整数类型的大小)的宏常量

發布時間:2025/3/11 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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} Macro constant DescriptionValue*
CHAR_BITIt returns the number of its in a char object.8
SCHAR_MINIt returns the minimum value of a signed char object.-128
SCHAR_MAXIt returns the maximum value of a signed char object.127
UCHAR_MAXIt returns the maximum value of an unsigned char object.255
CHAR_MINIt returns the minimum value of a char object.0 or SCHAR_MIN
CHAR_MAXIt returns the maximum value of a char objectSCHAR_MAX or UCHAR_MAX
MB_LEN_MAXIt returns the maximum number of bytes in a multibyte character, for any locale 1 or greater
SHRT_MINIt returns the minimum value of a signed short int object.-32768
SHRT_MAXIt returns the maximum value of a signed short int object.32767
USHRT_MAXIt returns the maximum value of an unsigned short int object.65535
INT_MINIt returns the minimum value of a signed int object.-32768 or -2147483648
INT_MAXIt returns the maximum value of a signed int object.32767 or 2147483647
UINT_MAXIt returns the maximum value of an unsigned int object.65535 or 4294967295
LONG_MINIt returns the minimum value of a signed long int object.-2147483648 or -9223372036854775808
LONG_MAXIt returns the maximum value of a signed long int object.2147483647 or 9223372036854775807
ULONG_MAXIt returns the maximum value of an unsigned long int object.4294967295 or 18446744073709551615
LLONG_MINIt returns the minimum value of a signed long long int object.-9223372036854775808
LLONG_MAXIt returns the maximum value of a signed long long int object.9223372036854775807
ULLONG_MAXIt 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 ++中(整数类型的大小)的宏常量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。