bit manipulation - How do you reverse the significant bits of an integer in python? -


What is the best way to reverse the critical bit of an integer in a dragon, and after that the result is a whole?

  the original reverse 1 0001 - 1000 - 8 2 - 0010 - 0100 - 4 5 - 0101 - 1010 - 10 15 - 1111 - 1111 - 15   

Given that these numbers are 32 bit integers. How should I do this in Python? I am unsure about this part of how to move individual bits into python and if there is any strange thing about using the 32bit field as an integer.

PS It's not a homework, I'm just trying to solve a logic puzzle.

  reversed_ = sum (1   For the category i (numbits if the original> gtc: i & amp; 1)    

Comments