How to check if the binary representation of an integer is a palindrome?
Hopefully correct:
_Bool is_palindrome(unsigned n) { unsigned m = 0; for(unsigned tmp = n; tmp; tmp >>= 1) m = (m << 1) | (tmp & 1); return m == n; }
1.4m articles
1.4m replys
5 comments
57.0k users