hi ,
what is the value of
-8>>-1
-8<<-1
it will be like
public class BitOperation {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(-8 << -1);
System.out.println(-8 >> -1);
}
}
the result is
0
-1
but if not -8, what will be the value?and why???
Thomas Schodt - 10 May 2006 10:10 GMT
> hi ,
>
[quoted text clipped - 21 lines]
> 0
> -1
int bitshift only uses the last 5 bits of the right hand side argument
(long bitshift uses the last 6 bits).
-1 & 0x1f is 31
the rest is obvious.