```
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
if(n == 0)
return 0;
long int rst = 0;
long int temp;
int step = 0;
while(step <= 31)
{
temp = n & 1;
n = n >> 1;
if(temp != 0)
rst += (temp<<(31 - step));
step++;
}
return rst;
}
};
```