Originally posted by amolpalekar kadolkar:
...In this your number of bits to be shifted is greater thn actual number
so we use formulae
32%2=0 then we use 0>>>2 and 0>>2= 0/2pow2=0
0 is my ans...
I think what you're looking for is something like: If the amount of the shift (the right-hand operand) is greater than the number of bits in the type (32 for int, or 64 for long), then shift by the remainder after division by the number of bits in the type.
For example, if x is an int, then for x >>> 35, you would use x >>> (35%32), which is x >>> 3.
Technically, for int shifting, only the last 5 bits of the right-hand operand are used, so the shift will always be between 0 and 31 inclusively (even if the right-hand operand is negative). For long shifting, only the last 6 bits of the right-hand operand are used, so the shift will always be between 0 and 63 inclusively.
Also, note that bit shifting is on the 1.4 exam, but
not on the 1.5 exam.