The basic types of integers in Java are Byte,short,int,long, 1, 2, 4, 8 bytes in size, and a byte size of 8 bits, which is 8 binary codes (0/1).
The binary code in the computer is divided into the original code, the inverse code, the complement. The number in the computer is stored in the original code, and negative numbers are stored in twos.
The original code is in the form represented in the machine, the first 1 represents a negative number, and 0 represents a positive number. For example, in the case of byte type, 0000 0001 represents a positive number 1,1111 1111 represents-1. Positive number of the original code, anti-code, the same complement, negative number of the anti-code for the original code in addition to the symbol bit, the other bit reverse. The complement is the inverse code plus 1. For example, 3 of the original code is 1000 0011, the anti-code is 1111 1100, the number in the computer is 1111 1101. Complement the original code with the same complement to the original code.
NOTE: 1000 0000 on the computer represents-128.
In Java if two-128 is added, regardless of rounding, the result is 1 0000 0000, because the byte type, so 1 is discarded, and the final result is 0.
Similarly integer.max_value+integer.max_value results are-2.
Binary implementations of Java plus and minus