```
public class Solution {
public int rangeBitwiseAnd(int m, int n) {
int ret = 0;
int index = 1 << 30;
while (index > 0)
{
if ((m & index) > 0 && (n & index) > 0)
{
ret = ret | index;
}
else if ((m & index) > 0 || (n & index) > 0)
{
return ret;
}
index = index >> 1;
}
return ret;
}
}
```