{lang: 'en-US'}

Why 2,147,483,647? MapleStory




Quote:
Originally Posted by SoldMySoul View Post
For simplicity...

Lets say the programmer creates a variable is stored what is the amount of mesos you have, the computer will allocate 32 cells in the memory to store this data with each cell only able to contain a ‘1’ or ‘0’. So with this we will have 2^32 possible combinations.

So value
0 = 00000000,00000000,00000000,00000000
1 = 00000000,00000000,00000000,00000001
2 = 00000000,00000000,00000000,00000010
3 = 00000000,00000000,00000000,00000011
.
.
.
.
4294967295 = 11111111,11111111,11111111,11111111

But take note, all the values above are positive as we did not store the information of the sign (‘+’ or ‘-‘) in the data. To store the sign value in the data what we do is we use the <-- most bit as a flag; if it is a 1, it means the variable has a negative value; if it is a 0, it is a positive value…

Since we are using 1 of the bit as a flag so only 31 bit is used to store the data and the max number of possible combination we can have will be 2^31 which is 2147483648. With only 2147483648 possible combinations, we will have 2147483648 negative values, 2147483648 positive values with 0 as a positive value.

So the range of the variable will become from -2147483648 to +2147483647… Hope this help.
http://forums.asiasoftsea.net/showthread.php?t=823512

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks