Last active
April 19, 2017 19:22
-
-
Save n1chre/f1c11688da66a2b04e0843f5321d4714 to your computer and use it in GitHub Desktop.
Check if a number is its own binary palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int is_binary_palindrome(int x){ | |
int b = 0, _x = x; | |
while (_x) { | |
b <<= 1; | |
b |= _x&1; | |
_x >>= 1; | |
} | |
return x==b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment