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


当前回答

如果你能记住圆周率的整个数字,那么你要找的数字在圆周率的十进制数字1867996680到1867996689的位置

数字字符串2147483647出现在圆周率的十进制数字1,867,996,680。3.14......86181221809936452346214748364710527835665425671614…

来源:http://www.subidiom.com/pi/

其他回答

使用Java 9的REPL, jshell:

$ jshell
|  Welcome to JShell -- Version 9-Debian

jshell> System.out.println(Integer.MAX_VALUE)
2147483647

Int32意味着你有32位可用来存储你的数字。最高位是符号位,这表示数字是正还是负。所以正数和负数都有2^31位。

如果0是正数,则得到(前面提到过)的逻辑范围

+2147483647到-2147483648

如果你认为这太小了,请使用Int64:

+9223372036854775807 至 -9223372036854775808

你为什么要记住这个号码?在代码中使用?您应该始终使用Int32。MaxValue或Int32。因为这些是静态值(在.net核心中),因此使用起来比用代码创建一个新的int更快。

我的陈述:如果能记住这个数字。你这是在炫耀!

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

答案是2147,483,647

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

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

无论如何,取这个正则表达式(它确定字符串是否包含一个十进制形式的非负整数,也不大于Int32.MaxValue)

[0-9] {1, 9} | [0, 1] [0-9] {1, 8} | 20 [0-9] {1, 8} | 21 [0, 3] [0-9] {1, 7} | 214 [0-6] [0-9] {1, 7} | 2147 [0, 3] [0-9] {1, 6} | 21474 [0] [0-9] {1, 5} | 21 4748 [2-0] [0-9] {1, 4} | 2147483 [0 to 5] [0-9] {1, 3} | 21474836 [0, 3] [0-9] {1, 2} | 214748364 [0]

也许能帮你记起来。

最简单的方法是查看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;
}