Package p20140207;
public class T20140207 {public
static void Main (string[] args)
{
int test =integer.max_value;
System.out.println ("no.1=" +test);
System.out.println ("no.2=" + (test+1));
System.out.println ("no.3=" + (test+1l));
}
Guess what the result would be?
The results are as follows: no.1= 2147483647
No.2=-2147483648
no.3= 2147483648
Package p20140207;
public class T20140207 {public
static void Main (string[] args)
{
int test =java.lang.integer.max_value;
System.out.println ("no.1=" +test);
System.out.println ("no.2=" + (test+1));
System.out.println ("no.3=" + (test+1l));
System.out.println ("no.4=" + (Math.pow (2));//int can represent 2 of 32 times = 4,294,967,296 digits
System.out.println ("no.5=" + ( Math.pow (2, 32)/2-1))//maximum number of representations
}
//0~2147483647 represent 0~2147483647
//2147483648~ 4294967295 respectively represents -2147483648~-1
//So when the 2147483647+1 becomes the No. 2147483648 number, it turns into -2147483648
}.
PS: When the operation is to use 2 of the complement of the calculation, the details are not specifically listed.