I can never remember the number. I need a memory rule.
我永远记不住那个号码。我需要一个记忆规则。
4501
It's 2,147,483,647. Easiest way to memorize it is via a tattoo.
它是2147483647。最简单的记忆方法就是纹身。
453
The most correct answer I can think of is Int32.MaxValue
.
我能想到的最正确的答案是Int32.MaxValue。
389
If you think the value is too hard to remember in base 10, try base 2: 1111111111111111111111111111111
如果你觉得在基地10很难记住这个值,试试基地2:111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
257
It's 10 digits, so pretend it's a phone number (assuming you're in the US). 214-748-3647. I don't recommend calling it.
它是10位数字,所以假设它是一个电话号码(假设你在美国)。214-748-3647。我不推荐这样称呼它。
191
if you can remember the entire Pi number, then the number you are looking for is at the position 1,867,996,680 till 1,867,996,689 of the decimal digits of Pi
如果你能记住整个圆周率,那么你要找的是圆周率小数点后1,867,996,680到1,867,996,689的位置
The numeric string 2147483647 appears at the 1,867,996,680 decimal digit of Pi. 3.14......86181221809936452346214748364710527835665425671614...
数字字符串2147483647出现在圆周率的1,867,996,680位上。
source: http://www.subidiom.com/pi/
来源:http://www.subidiom.com/pi/
151
Rather than think of it as one big number, try breaking it down and looking for associated ideas eg:
与其把它想成一个大数字,不如试着把它分解并寻找相关的想法。
The above applies to the biggest negative number; positive is that minus one.
以上适用于最大负数;正的是- 1。
Maybe the above breakdown will be no more memorable for you (it's hardly exciting is it!), but hopefully you can come up with some ideas that are!
也许以上的故障不会给你留下深刻的印象(这一点也不令人兴奋!),但希望你能想出一些点子!
135
Largest negative (32bit) value : -2147483648
(1 <<31)
最大负(32位)值:-2147483648 (1 <31)
Largest positive (32bit) value : 2147483647
~(1 <<31)
最大正(32位)值:2147483647 ~(1 <31)
Mnemonic: "drunk AKA horny"
助记:“醉又名角”
drunk ========= Drinking age is 21
AK ============ AK 47
A ============= 4 (A and 4 look the same)
horny ========= internet rule 34 (if it exists, there's 18+ material of it)
21 47 4(years) 3(years) 4(years)
21 47 48 36 48
63
Anyway, take this regex (it determines if the string contains a non-negative Integer in decimal form that is also not greater than Int32.MaxValue)
无论如何,使用这个regex(它确定字符串是否包含不大于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-7][0-9]{1,5}|214748[0-2][0-9]{1,4}|2147483[0-5][0-9]{1,3}|21474836[0-3][0-9]{1,2}|214748364[0-7]
[0 - 9]{ 1,9 } |(0 - 1)[0 - 9]{ 1,8 } | 20[0 - 9]{ 1,8 } | 21(0 - 3)[0 - 9]{ 1,7 } | 214年[-][0 - 9]{ 1,7 } | 2147(0 - 3)[0 - 9]{ 1,6 } | 21474(鹿)[0 - 9]{ 1,5 } | 214748年[0][0 - 9]{ 1 4 } | 2147483(0 - 5)[0 - 9]{ 1,3 } | 21474836(0 - 3)[0 - 9]{ 1,2 } | 214748364(鹿)
Maybe it would help you to remember.
也许这能帮你记住。
58
That's how I remembered 2147483647
:
这就是我对2147483647的记忆:
Write these horizontally:
写这些水平:
214_48_64_
and insert:
^ ^ ^
7 3 7 - which is Boeing's airliner jet (thanks, sgorozco)
Now you've got 2147483647.
现在你有2147483647。
Hope this helps at least a bit.
希望这至少能有所帮助。
53
2^(x+y) = 2^x * 2^y
2^10 ~ 1,000
2^20 ~ 1,000,000
2^30 ~ 1,000,000,000
2^40 ~ 1,000,000,000,000
(etc.)
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
So, 2^31 (signed int max) is 2^30 (about 1 billion) times 2^1 (2), or about 2 billion. And 2^32 is 2^30 * 2^2 or about 4 billion. This method of approximation is accurate enough even out to around 2^64 (where the error grows to about 15%).
2 ^ 31(int max)签署的是2 ^ 30(约10亿)* 2 ^ 1(2),或约20亿。和2 ^ 32是2 ^ 30 * 2 ^ 2约40亿。这种近似方法足够准确甚至2 ^ 64左右(误差增长约15%)。
If you need an exact answer then you should pull up a calculator.
如果你需要一个确切的答案,你应该用计算器。
Handy word-aligned capacity approximations:
方便的字之间对齐容量近似:
43
Just take any decent calculator and type in "7FFFFFFF" in hex mode, then switch to decimal.
只要使用任何像样的计算器,输入“7fffff”在十六进制模式,然后切换到十进制。
2147483647.
2147483647。
31
Here's a mnemonic for remembering 2**31, subtract one to get the maximum integer value.
这是记忆2**31的助记符,减去1得到最大整数值。
a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9
a = 1,b = 2,c = 3,d = 4,e = 5,f = 6,g = 7,h = 8,i = 9
Boys And Dogs Go Duck Hunting, Come Friday Ducks Hide
2 1 4 7 4 8 3 6 4 8
I've used the powers of two up to 18 often enough to remember them, but even I haven't bothered memorizing 2**31. It's too easy to calculate as needed or use a constant, or estimate as 2G.
我经常用2到18的幂来记住它们,但即使是我也懒得记住2**31。它太容易按需要计算或使用常数,或估计为2G。
31
32 bits, one for the sign, 31 bits of information:
32位,1位符号,31位信息:
2^31 - 1 = 2147483647
Why -1?
Because the first is zero, so the greatest is the count minus one.
为什么1 ?因为第一个是0,所以最大的数是- 1。
EDIT for cantfindaname88
编辑对cantfindaname88
The count is 2^31 but the greatest can't be 2147483648 (2^31) because we count from 0, not 1.
数是2 ^ 31但最不能2147483648(2 ^ 31)因为我们计数从0,而不是1。
Rank 1 2 3 4 5 6 ... 2147483648
Number 0 1 2 3 4 5 ... 2147483647
Another explanation with only 3 bits : 1 for the sign, 2 for the information
另一种解释只有3位:1表示符号,2表示信息。
2^2 - 1 = 3
Below all the possible values with 3 bits: (2^3 = 8 values)
与3位:下面的所有可能的值(2 ^ 3 = 8值)
1: 100 ==> -4
2: 101 ==> -3
3: 110 ==> -2
4: 111 ==> -1
5: 000 ==> 0
6: 001 ==> 1
7: 010 ==> 2
8: 011 ==> 3
28
Well, it has 32 bits and hence can store 2^32 different values. Half of those are negative.
嗯,它有32位,因此可以存储2 ^ 32个不同的值。其中一半是负数。
The solution is 2,147,483,647
解决方案是2147483647
And the lowest is −2,147,483,648.
和最低是2147483648−。
(Notice that there is one more negative value.)
(注意还有一个负值)
27
It's about 2.1 * 10^9
. No need to know the exact 2^{31} - 1 = 2,147,483,647
.
是2.1 * 10 ^ 9。不需要知道确切的2 ^ 31 } { - 1 = 2147483647。
CYou can find it in C like that:
你可以在C中找到
#include
#include
main() {
printf("max int:\t\t%i\n", INT_MAX);
printf("max unsigned int:\t%u\n", UINT_MAX);
}
gives (well, without the ,
)
给予(没有,)
max int: 2,147,483,647
max unsigned int: 4,294,967,295
C++ 11
std::cout <::max() <<"\n";
std::cout <::max() <<"\n";
Java
You can get this with Java, too:
Java也可以这样做:
System.out.println(Integer.MAX_VALUE);
But keep in mind that Java integers are always signed.
但是请记住,Java整数总是有符号的。
PythonPython has arbitrary precision integers. But in Python 2, they are mapped to C integers. So you can do this:
Python具有任意的精度整数。但是在Python 2中,它们被映射成C整数。你可以这样做:
import sys
sys.maxint
>>> 2147483647
sys.maxint + 1
>>> 2147483648L
So Python switches to long
when the integer gets bigger than 2^31 -1
所以Python开关长当整数大于2 ^ 31 - 1
25
At this point, I'd say the easiest mnemonic is to type "stackoverflow.com" TAB "maximum int32" into Chrome.
在这一点上,我认为最简单的助记符是将“stackoverflow.com”选项卡“maximum int32”输入到Chrome中。
There is a recursion --> stack overflow joke in there somewhere. I'm just not that geeky.
这里有一个递归——>栈溢出笑话。我只是没那么怪。
21
The easiest way to do this for integers is to use hexadecimal, provided that there isn't something like Int.maxInt(). The reason is this:
对于整数,最简单的方法是使用十六进制,前提是不存在Int.maxInt()之类的东西。原因是这样的:
Max unsigned values
马克斯无符号值
8-bit 0xFF
16-bit 0xFFFF
32-bit 0xFFFFFFFF
64-bit 0xFFFFFFFFFFFFFFFF
128-bit 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Signed values, using 7F as the max signed value
有符号值,使用7F作为最大有符号值
8-bit 0x7F
16-bit 0x7FFF
32-bit 0x7FFFFFFF
64-bit 0x7FFFFFFFFFFFFFFF
Signed values, using 80 as the max signed value
有符号值,使用80作为最大有符号值
8-bit 0x80
16-bit 0x8000
32-bit 0x80000000
64-bit 0x8000000000000000
How does this work? This is very similar to the binary tactic, and each hex digit is exactly 4 bits. Also, a lot of compilers support hex a lot better than they support binary.
这是如何工作的呢?这与二进制策略非常相似,每个十六进制数字恰好是4位。此外,许多编译器支持十六进制比支持二进制要好得多。
F hex to binary: 1111
8 hex to binary: 1000
7 hex to binary: 0111
0 hex to binary: 0000
So 7F is equal to 01111111 / 7FFF is equal to 0111111111111111. Also, if you are using this for "insanely-high constant", 7F... is safe hex, but it's easy enough to try out 7F and 80 and just print them to your screen to see which one it is.
所以7F等于01111111 / 7FFF等于0111111111111111。另外,如果你用这个来表示“高得离谱的常数”,7F…是安全的十六进制,但是很容易尝试7F和80,然后把它们打印到你的屏幕上看看是哪一个。
0x7FFF + 0x0001 = 0x8000, so your loss is only one number, so using 0x7F... usually isn't a bad tradeoff for more reliable cod