Possible Duplicate:
C reverse bits in unsigned integer
How can I reverse a binary number only using binary operators?
E.g:
11100000 -> 00000111
00110100 -> 00101100
00111111 -> 11111100
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For this sort of thing I recommend that you take a look at the awesome page Bit Twiddling Hacks.
Here is just one example solution taken from that page:
And as pointed out in the comments, here’s another option: