C reverse bits in unsigned integer
I'm converting an unsigned integer to binary using bitwise operators, and currently do integer & 1 to check if bit is 1 or 0 and output, then right shift by 1 to divide by 2. However the bits are returned in the wrong order (reverse), so I thought to reverse the bits order in the integer before beginning. Is there a simple way to do this? Example: So if I'm given the unsigned int 10 = 1010 while (x not eq 0) if (x & 1) output a '1' else output a '0' right shift x by 1 this returns 0101 which is incorrect... so I was thinking to reverse the order of the bits originally before running the loop,