我总是记不住电话号码。我需要一个记忆规则。


当前回答

它是2147483647。最简单的记忆方法就是纹身。

其他回答

随便找个计算器,在十六进制模式下输入“7FFFFFFF”,然后切换到十进制。

2147483647.

首先写出两次47(你喜欢47号特工,对吧?),保持如图所示的空格(每个破折号是一个数字的槽位。先2个,然后4个)

--47----47

认为你手里有12个(因为12 =一打)。将其乘以4,47号特工号的第一位数字,即47,并将结果放在你已经拥有的第一对的右边

12 * 4 = 48
--4748--47 <-- after placing 48 to the right of first 47

然后将12乘以3(为了得到47号特工的数字的第二个数字,即7,你需要7 - 4 = 3),并将结果放在前两对的右边,即最后一个对槽

12 * 3 = 36
--47483647 <-- after placing 36 to the right of first two pairs

最后,从最右边的数字(本例中为2)开始,一个接一个地从您的手中拖动数字,并将它们放在您获得的第一个空槽中

2-47483647 <-- after placing 2
2147483647 <-- after placing 1

你知道了!对于负极限,你可以认为它的绝对值比正极限大1。

练习几次,你就会掌握窍门的!

它有32位,因此可以存储2^32个不同的值。其中一半是负面的。

答案是2147,483,647

最低的是- 2,147,483,648。

(注意这里多了一个负数。)

“如果一个巨大的整数没有被回忆起,你就回忆这个助记符。”

现在数数每个单词中的字母。

最简单的方法是查看std::numeric_limits< int >::max()

例如(来自MSDN),

// numeric_limits_max.cpp

#include <iostream>
#include <limits>

using namespace std;

int main() {
   cout << "The maximum value for type float is:  "
        << numeric_limits<float>::max( )
        << endl;
   cout << "The maximum value for type double is:  "
        << numeric_limits<double>::max( )
        << endl;
   cout << "The maximum value for type int is:  "
        << numeric_limits<int>::max( )
        << endl;
   cout << "The maximum value for type short int is:  "
        << numeric_limits<short int>::max( )
        << endl;
}