java int

  JAVA is a Unicode-encoded. 8 bits per byte. 32-bit system, each int 4 bytes, 32-bit.
  byte is a Java primitive types. byte integer value may be stored within the range [-128,127] a.
  All the integer values are 32-bit Java int value, unless l or L (such as 235L) after the value, which indicates that the value should be interpreted to a long.

  java in the range idea int is calculated as follows: 32 filled lattice method is 0 or 1 2 ^ 32 species. Therefore, there are two possibilities, two kinds of estimation methods:
1, the maximum number of binary (32 1) into a decimal, i.e. 4294967296
2, 32 th algorithms 2, then in accordance with the maximum number of decimal 10 32 is a power of 2. That is 4294967296.
Therefore, the range of int java: the 31 th power of 2: + 2147483648

  int ranges: 31--2 ^ -2 ^ 31-1, i.e. -2147483648--2147483647
1, for positive numbers, it is its own complement.
2, for the negative, it's complement binary number is a positive number which corresponds to all the bits after inversion plus one.
3, a negative complement find the original code is the same operation (all the bits + 1) is the absolute value of the negative
  int is 4 bytes, 32-bit,
  1,000,000,000,000,000 00000000 00000000 is the complement of the first one it is the sign bit indicates a negative number, so that
  the remaining bit inverse, 111,111,111,111,111 1,111,111,111,111,111 result, after adding an 10000000 00000000 00000000
4 so that the original code refers -2 ^ 31 = -2147483648.

int range of 31--2 ^ 31-1 ^ -2
  unsigned int can represent the maximum value of 2 ^ 32-1. As for the reason, read the following examples will understand:
Suppose a microcontroller with two binary to represent numbers, it is clear that 00, four cases, respectively, 0,1,2,3 four number.
That's right, the original 0 state also occupied a total of 16-bit binary number can represent 2 ^ 32 states can only represent 0 to 2 ^ 32-1, namely the 0 to 32767.
(A box can store a number of data, but the storage limit is the number of multiples of two. Now we have to go into an integer, integer if only positive and negative integers it easier to handle, one half of the space.
May also be chosen integer contains a zero. this allows patients with obsessive-compulsive disorder is difficult to accept, but the computer system designer must take this into account, and consequently no 0 not, people have to occupy the space.
I fear, is a positive integer or negative integer from the other side of that side a uniform over space, 32 th -12 is relatively simple and easy to remember, it is a positive integer from there a uniform space over it.)

    1000  0000   0000  0000   0000   0000   0000   0000                         Integer.MIN_VALUE 

  After negated 0,111,111,111,111,111 1,111,111,111,111,111 negated become Integer.MAX_VALUE

Plus 1 1000 0000 0000 0000 0000 0000 0000 0000 -Integer.MIN_VALUE (as with the original result)

Above all from the online search finishing ......

Guess you like

Origin www.cnblogs.com/adlin-forever/p/11529020.html