Why is -1 right shift 1 = -1 in Java?

Viewed 839

I came across the question "Why is -1 zero fill right shift 1=2147483647 for integers in Java?"

I understood the concept of zero fill right shift perfectly well from the above question's answer. But when I tried to find -1>>1, I am getting a totally complex answer which I felt difficult to understand.

-1 in binary form is as follows: 11111111111111111111111111111111
After flipping the bits, I got:  00000000000000000000000000000000
Upon adding 1 to it, I got:      00000000000000000000000000000001
Now shifting one position right: 00000000000000000000000000000000 
After flipping the bits, I got:  11111111111111111111111111111111
Now adding 1 to it:              00000000000000000000000000000000

I don't understand how -1>>1 is -1 itself, then?

2 Answers
Related