Community
Participate
Working Groups
Build ID: I20080617-2000 Consider the following source code: byte b1 = -3; byte b2 = -3; b1 >>>= 1; b2 >>>= 25; System.out.println(b1); System.out.println(b2); The output is: -2 127 Actually, i'd expect >>>=1 to shift the data right, filling the left side with zeros therefore resulting in a positive number. But this doesn't work for the data types byte and short. The semantics of "b1 >>>= 1" is: b1 = (byte)( ((int)b1) >>> 1 ) I would say, this is VERY counter-intuitional. The b2 >>>= 25 explicitly exploits the idea, since it shift by 25 bits, which results in the desired 8 bits. So you have some nice compiler-warnings concerning semantics: - accidental assignments - using char[] in string concat - etc. So this might be another candidate. Please add a compiler-warning if the >>>= operator is applied to byte or short values. Most people will not be aware, what they did there. (And an explanation is hard to find)