Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00111001011110000010100101000000).

无符号×××数据的反转,一般采用位操作,左移<<,右移>>,且&,或|等操作

public class Solution {

    // you need treat n as an unsigned value

    public int reverseBits(int n) {

        int m=n&1;

        for(int i=1;i<32;i++)

        {

            m=m<<1;

            n=n>>1;

            m=m|(n&1);

        }

        return m;

    }

}