```
public class Solution {
// you need treat n as an unsigned value
public int reverseBits(int n) {
long result = 0L;
int i=0;
for(;n!=0&&i<32;i++,n>>=1){
result<<=1;
result|=(n&1);
}
return (int)result<<(32-i);
}
```

}