When a long integer is cast into a short one, what happened?
问题 I use java to copy one long integer y to a short integer x: long y = 40002; short x = (short) y; System.out.println("x now equals " + x); The result is: x now equals -25534. I tried to figure out how 40002 was cast into -25534, but I failed. The 40002 corresponds to 1001 1100 0100 0010, the -25534 corresponds to 1110 0011 1011 1110. Can any friend tell me what happened in this process? Thanks a lot! 回答1: What you have done by casting a long to a short is a narrowing primitive conversion ,