整数类型 | 等价类型 | C++11标准规定占用最少位数 |
---|---|---|
short | short int(有符号短整型) | 至少 16 位(2 个字节) |
signed short | ||
signed short int | ||
unsigned short | unsigned short int(无符号短整型) | |
unsigned short int | ||
int | int(有符号整形) | 至少 16 位(2 个字节) |
signed | ||
signed int | ||
unsigned | unsigned int(无符号整形) | |
unsigned int | ||
long | long int(有符号长整形) | 至少 32 位(4 个字节) |
long int | ||
signed long | ||
signed long int | ||
unsigned long | unsigned long int(无符号长整形) | |
unsigned long int | ||
long long(C++11) | long long int(有符号超长整形) | 至少 64 位(8 个字节) |
long long int(C++11) | ||
signed long long(C++11) | ||
signed long long int(C++11) | ||
unsigned long long(C++11) | unsigned long long int(无符号超长整型) | |
unsigned long long int(C++11) |
<climits>
头文件中与 long long 整形相关的 3 个宏,分别为 LLONG_MIN、LLONG_MAX 和 ULLONG_MIN:
#include <iostream> #include <iomanip> #include <climits> using namespace std; int main() { cout <<"long long最大值:" << LLONG_MIN <<" "<< hex << LLONG_MIN <<"\n"; cout << dec <<"long long最小值:" << LLONG_MAX << " " << hex << LLONG_MAX << "\n"; cout << dec << "unsigned long long最大值:" << ULLONG_MAX << " " << hex << ULLONG_MAX; return 0; }程序执行结果为(不唯一):
long long最大值:-9223372036854775808 8000000000000000
long long最小值:9223372036854775807 7fffffffffffffff
unsigned long long最大值:18446744073709551615 ffffffffffffffff
本文链接:http://task.lmcjl.com/news/7700.html