posted 20 years ago
hi:
You are right. After the >>> operator x times, the leading x bits is 0s(the left most bits). However, if you cast it to lower number of bits, it might result in a negative number. here is an example:
00000000 00000000 00000011 11111111 // int x = 1023
1- x >>> 2 = 255 // 00000000 00000000 00000000 11111111
2- byte y = (byte) x; // 11111111
In statement 2, we trimmed the int to a byte, which result in a negative number.
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle