Look directly at the following operations:
public class Testconvert{public static void Main (String []args) {byte b1=67;byte b2=89;byte b= (Byte) (B1+B2);// The system casts an int type operation, which requires a cast System.out.println (b);}}
Analysis: The storage space of byte type is 1 bytes, the storage space of the range is -128~127;int type is 4 bytes;
BYTE b1= 67=01000011;//sign bit is positive
BYTE b2= 89=01011001;//sign bit is positive
01000011
+ 01011001
----------------------------------
10011100 (exceeding the upper limit of the expression range, the sign bit is 1, indicating negative numbers)
10011100 to 01100011 and add 1->01100100
IE-(64+32+4) =-100
Here is mainly related to decimal to binary conversion, complement, anti-code!
This is the personal idea, if there is the wrong place also please elegance!
Int,byte of Java data type conversion