I recently read an interesting article about the >>> operator... int i = 3; System.out.println(i >>> 1) ----> prints 1; System.out.println(i >>> 2) ----> prints 0; System.out.println(i >>> 3...31) ----> prints 0; System.out.println(i >>> 32) ----> GUESS WHAT ---> prints 3; HOW??? i >>> (32%32) = 3. This is based on the variable data type. If is long then i >>> 64 would print 3. Sivaram.
Any Shift by 32 means no shift at all. This is because a mod 32 operation is performed on the # of bits to be shifted operator and when the # of bits to be shifted is 32, it is actually 32%32 which is 0 bits to be shifted. HTH
Yep, rule of thumb is if the number of bits being shifted is greater than the bit-size of the data type of number being shifted, the actual shift will happen only by the result of reminder division of latter by former. ie., if x being shifted by y bits and if y is greater than sizeof x ( number of bits, not bytes!! ), then the actual shift will occur only by y%x ( read as y mod x ). Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Look! It's Leonardo da Vinci! And he brought a tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth