I am just stuck with this small logic that i am not getting it right
int
is 32 bits so suppose taking 20 in binary would be like
// 00000000000000000000000000010100
.. now if I perform rightshift operation say 4
int a = 20>>4;
// 00000000000000000000000000000001
..so result is 1
Now say I again take 20 and do 5 right shift operation
int b = 20>>5; //00000000000000000000000000000000
..so result is 0
Now if I do 32 right shift ... why I am getting the same number as I assigned.??
int c = 20>>32; //how does this prints 20 again??
System.out.println("right shift 4= "+a+"\n right shift 5= "+b+"right shift 32 = "+c);
So what I was expecting is after 5 shifts ..any number of shifts should have resulted in the result 0.. but on 32 shifts why I am getting back the assigned value?