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
The Best way to reverse the bit in an integer is:
CODE SNIPPET
int reverse ( unsigned int n ) { int x = 0; int mask = 1; while ( n > 0 ) { x = x << 1; if ( mask & n ) x = x | 1; n = n >> 1; } return x; }