Login Register

  • Share your knowledge and help people by answering questions.


  • How

    How to reverse the bits in an integer?

    No Comments...

    Asked in TechnologyComputers
    Answered 1 year ago

    shastri

    The following C code can be used to reverse bits in an integer.

    #include

    long reverse(unsigned long x) {
    long rev = 0;
    int i = 0;

    for(rev = i = 0; i < 32; i++) {
    rev = (rev << 1) + (x & 1);
    x >>= 1;
    }

    return rev;
    }

    Sign In to answer


Similar Questions





Banner

About Us | Our Blog | Terms and Conditions | Disclaimer | Sitemap | Contact Us
© Copyrights 2010 AskW5H.com. All Rights Reserved