public class Solution {

// you need treat n as an unsigned value

public int reverseBits(int n) {

```
int j=0,result=0;
for(int i=0;i<32; i++) {
if((n&1)==1) j += 1;
result=j;
j <<= 1;//31 times
n >>= 1;//right one bit
}
return result;
}
```

}