my @num = $line =~ /(\d+)/g;
输出: 长和长的长变量产生完全相同的最大值,我不知道为什么。 long值应该输出最大值2147483647。
#include <iostream>
using namespace std;
#include <climits>
int main () {
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;
long long n_llong = LLONG_MAX;
cout << "int is " << sizeof (int) << " bytes." << endl;
cout << "short is " << sizeof n_short << " bytes." << endl;
cout << "long is " << sizeof n_long << " bytes." << endl;
cout << "long long is " << sizeof n_llong << " bytes." << endl;
cout << endl;
cout << "Maximum values:" << endl;
cout << "int: " << n_int << endl;
cout << "short: " << n_short << endl;
cout << "long: " << n_long << endl;
cout << "llong: " << n_llong << endl << endl;
//cout << endl;
cout << "Minimum int value = " << INT_MIN << endl;
cout << "Maximum int value = " << INT_MAX << endl;
cout << "Bits per byte = " << CHAR_BIT << endl;
return 0;
}
答案 0 :(得分:9)
long
不保证是32位长;它只需至少 32位长。您的实现已将long
定义为64位。请注意,即使long
和long long
在您的实现上具有相同的范围,但它们仍然是不同的类型。