先日書いたのと同じはなしなんだが、もうちょっと不幸そうな例を思いついたのでソースと実行結果を書いておく。
まずはソース:
public class Test1 { static void test( int i ){ short x=0x4321; x<<=i; System.out.printf( "%d : %x\n", i, x); } public static void main(String[] args) { for( int i=15 ; i<35 ; ++i) test(i); } }
実行結果は、先日の解説の通り、
15 : 8000
16 : 0
17 : 0
18 : 0
19 : 0
20 : 0
21 : 0
22 : 0
23 : 0
24 : 0
25 : 0
26 : 0
27 : 0
28 : 0
29 : 0
30 : 0
31 : 0
32 : 4321
33 : 8642
34 : c84
となる。
31と32の間の断絶が切ない。