Question

I can never remember the number. I need a memory rule.

Was it helpful?

Solution

It's 2,147,483,647. Easiest way to memorize it is via a tattoo.

OTHER TIPS

The most correct answer I can think of is Int32.MaxValue.

If you think the value is too hard to remember in base 10, try base 2: 1111111111111111111111111111111

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

The numeric string 2147483647 appears at the 1,867,996,680 decimal digit of Pi. 3.14......86181221809936452346214748364710527835665425671614...

source: http://www.subidiom.com/pi/

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.

Rather than think of it as one big number, try breaking it down and looking for associated ideas eg:

  • 2 maximum snooker breaks (a maximum break is 147)
  • 4 years (48 months)
  • 3 years (36 months)
  • 4 years (48 months)

The above applies to the biggest negative number; positive is that minus one.

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!

Largest negative (32bit) value : -2147483648
(1 << 31)

Largest positive (32bit) value : 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

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)

[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]

Maybe it would help you to remember.

That's how I remembered 2147483647:

  • 214 - because 2.14 is approximately pi-1
  • 48 = 6*8
  • 64 = 8*8

Write these horizontally:

214_48_64_
and insert:
   ^  ^  ^
   7  3  7 - which is Boeing's airliner jet (thanks, sgorozco)

Now you've got 2147483647.

Hope this helps at least a bit.

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%).

If you need an exact answer then you should pull up a calculator.

Handy word-aligned capacity approximations:

  • 2^16 ~= 64 thousand // uint16
  • 2^32 ~= 4 billion // uint32, IPv4, unixtime
  • 2^64 ~= 16 quintillion (aka 16 billion billions or 16 million trillions) // uint64, "bigint"
  • 2^128 ~= 256 quintillion quintillion (aka 256 trillion trillion trillions) // IPv6, GUID

Just take any decent calculator and type in "7FFFFFFF" in hex mode, then switch to decimal.

2147483647.

It's about 2.1 * 10^9. No need to know the exact 2^{31} - 1 = 2,147,483,647.

C

You can find it in C like that:

#include <stdio.h>
#include <limits.h>

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 << std::numeric_limits<int>::max() << "\n";
std::cout << std::numeric_limits<unsigned int>::max() << "\n";

Java

You can get this with Java, too:

System.out.println(Integer.MAX_VALUE);

But keep in mind that Java integers are always signed.

Python 2

Python has arbitrary precision integers. But in Python 2, they are mapped to C integers. So you can do this:

import sys
sys.maxint
>>> 2147483647
sys.maxint + 1
>>> 2147483648L

So Python switches to long when the integer gets bigger than 2^31 -1

Here's a mnemonic for remembering 2**31, subtract one to get the maximum integer value.

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.

32 bits, one for the sign, 31 bits of information:

2^31 - 1 = 2147483647

Why -1?
Because the first is zero, so the greatest is the count minus one.

EDIT for cantfindaname88

The count is 2^31 but the greatest can't be 2147483648 (2^31) because we count from 0, not 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

2^2 - 1 = 3

Below all the possible values with 3 bits: (2^3 = 8 values)

1: 100 ==> -4
2: 101 ==> -3
3: 110 ==> -2
4: 111 ==> -1
5: 000 ==>  0
6: 001 ==>  1
7: 010 ==>  2
8: 011 ==>  3

Well, it has 32 bits and hence can store 2^32 different values. Half of those are negative.

The solution is 2,147,483,647

And the lowest is −2,147,483,648.

(Notice that there is one more negative value.)

At this point, I'd say the easiest mnemonic is to type "stackoverflow.com" TAB "maximum int32" into Chrome.

There is a recursion --> stack overflow joke in there somewhere. I'm just not that geeky.

Well, aside from jokes, if you're really looking for a useful memory rule, there is one that I always use for remembering big numbers.

You need to break down your number into parts from 3-4 digits and remember them visually using projection on your cell phone keyboard. It's easier to show on a picture:

enter image description here

As you can see, from now on you just have to remember 3 shapes, 2 of them looks like a Tetris L and one looks like a tick. Which is definitely much easier than memorizing a 10-digit number.

When you need to recall the number just recall the shapes, imagine/look on a phone keyboard and project the shapes on it. Perhaps initially you'll have to look at the keyboard but after just a bit of practice, you'll remember that numbers are going from top-left to bottom-right so you will be able to simply imagine it in your head.

Just make sure you remember the direction of shapes and the number of digits in each shape (for instance, in 2147483647 example we have a 4-digit Tetris L and a 3-digit L).

You can use this technique to easily remember any important numbers (for instance, I remembered my 16-digit credit card number etc.).

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:

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

8-bit 0x7F
16-bit 0x7FFF
32-bit 0x7FFFFFFF
64-bit 0x7FFFFFFFFFFFFFFF

Signed values, using 80 as the max signed value

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.

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.

0x7FFF + 0x0001 = 0x8000, so your loss is only one number, so using 0x7F... usually isn't a bad tradeoff for more reliable code, especially once you start using 32-bits or more

First write out 47 twice, (you like Agent 47, right?), keeping spaces as shown (each dash is a slot for a single digit. First 2 slots, then 4)

--47----47

Think you have 12 in hand (because 12 = a dozen). Multiply it by 4, first digit of Agent 47's number, i.e. 47, and place the result to the right of first pair you already have

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

Then multiply 12 by 3 (in order to make second digit of Agent 47's number, which is 7, you need 7 - 4 = 3) and put the result to the right of the first 2 pairs, the last pair-slot

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

Finally drag digits one by one from your hand starting from right-most digit (2 in this case) and place them in the first empty slot you get

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

There you have it! For negative limit, you can think of that as 1 more in absolute value than the positive limit.

Practise a few times, and you will get the hang of it!

2GB

(is there a minimum length for answers?)

If you happen to know your ASCII table off by heart and not MaxInt :
!GH6G = 21 47 48 36 47

The best rule to memorize it is:
21 (magic number!)
47 (just remember it)
48 (sequential!)
36 (21 + 15, both magics!)
47 again

Also it is easier to remember 5 pairs than 10 digits.

Assuming .NET -

Console.WriteLine(Int32.MaxValue);

Interestingly, Int32.MaxValue has more characters than 2,147,486,647.

But then again, we do have code completion,

So I guess all we really have to memorize is Int3<period>M<enter>, which is only 6 characters to type in visual studio.

UPDATE For some reason I was downvoted. The only reason I can think of is that they didn't understand my first statement.

"Int32.MaxValue" takes at most 14 characters to type. 2,147,486,647 takes either 10 or 13 characters to type depending on if you put the commas in or not.

The easiest way to remember is to look at std::numeric_limits< int >::max()

For example (from 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;
}

Just remember that 2^(10*x) is approximately 10^(3*x) - you're probably already used to this with kilobytes/kibibytes etc. That is:

2^10 = 1024                ~= one thousand
2^20 = 1024^2 = 1048576    ~= one million
2^30 = 1024^3 = 1073741824 ~= one billion

Since an int uses 31 bits (+ ~1 bit for the sign), just double 2^30 to get approximately 2 billion. For an unsigned int using 32 bits, double again for 4 billion. The error factor gets higher the larger you go of course, but you don't need the exact value memorised (If you need it, you should be using a pre-defined constant for it anyway). The approximate value is good enough for noticing when something might be a dangerously close to overflowing.

this is how i do it to remember 2,147,483,647

To a far savannah quarter optimus trio hexed forty septenary

2 - To
1 - A
4 - Far
7 - Savannah
4 - Quarter
8 - Optimus
3 - Trio
6 - Hexed
4 - Forty
7 - Septenary

What do you mean? It should be easy enough to remember that it is 2^32. If you want a rule to memorize the value of that number, a handy rule of thumb is for converting between binary and decimal in general:

2^10 ~ 1000

which means 2^20 ~ 1,000,000

and 2^30 ~ 1,000,000,000

Double that (2^31) is rounghly 2 billion, and doubling that again (2^32) is 4 billion.

It's an easy way to get a rough estimate of any binary number. 10 zeroes in binary becomes 3 zeroes in decimal.

As a physicist I would just round to 2 billion (semi-joke). Easy to remember!

In Objective-C (iOS & OSX), just remember these macros:

#define INT8_MAX         127
#define INT16_MAX        32767
#define INT32_MAX        2147483647
#define INT64_MAX        9223372036854775807LL

#define UINT8_MAX         255
#define UINT16_MAX        65535
#define UINT32_MAX        4294967295U
#define UINT64_MAX        18446744073709551615ULL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top