錛?錛夊拰鍗佽繘鍒舵暟涓嶅悓錛屽綋鍗佸叚榪涘埗銆佸叓榪涘埗鏁扮殑鏈楂樹綅鏄?鏃訛紝琛ㄧず瀹冩槸涓涓礋鏁幫紙鍦ㄥ崄榪涘埗鏁頒腑錛岃〃紺轟竴涓礋鏁拌鏄懼紡浣跨敤絎﹀彿-)
錛?錛夊敖閲忛伩鍏嶆販鍚堢被鍨嬭繍綆楋紝渚嬪鏈緥涓殑 long鍨嬪拰int鍨嬬殑鍔犳硶錛屽湪java涓紝涓涓暣鏁板鏋滄病鏈夊悗緙L鎴杔錛屽垯瀹冩槸涓涓猧nt鍨嬭屼笉鏄痩ong鍨嬨?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">

JoyOfHex.java
public聽class聽JoyOfHex
{
聽聽聽聽public聽static聽void聽main(String[]聽args)
聽聽聽聽{
聽聽聽聽聽聽聽聽System.out.println(Long.toHexString(0x100000000L聽+聽0xcafebabe));//cafebabe聽instead聽of聽1cafebabe
聽聽聽聽聽聽聽聽System.out.println(Long.toHexString(0x100000000L聽+聽0xcafebabeL));聽//聽1cafebabe
聽聽聽聽聽聽聽聽System.out.println(0xffffffffL);聽//聽4294967295
聽聽聽聽聽聽聽聽System.out.println(0xffffffff);聽//聽-1
聽聽聽聽}
}
Puzzle 6:
The rule "Sign
extension is performed if the type of the original value is signed;
zero extension if it is a char, regardless of the type to which it is
being converted" describes the sign extension behavior when converting from narrower integral types to wider.