Skip to content

Instantly share code, notes, and snippets.

@n1chre
Last active April 19, 2017 19:22
Show Gist options
  • Save n1chre/f1c11688da66a2b04e0843f5321d4714 to your computer and use it in GitHub Desktop.
Save n1chre/f1c11688da66a2b04e0843f5321d4714 to your computer and use it in GitHub Desktop.
Check if a number is its own binary palindrome
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