Skip to content

Instantly share code, notes, and snippets.

@beiweiqiang
Created June 20, 2018 14:37
Show Gist options
  • Save beiweiqiang/922b5f57dafe134ad017ae886e9b78ff to your computer and use it in GitHub Desktop.
Save beiweiqiang/922b5f57dafe134ad017ae886e9b78ff to your computer and use it in GitHub Desktop.
所有位为 0 时返回 1, 其它情况返回 0
#include <stdio.h>
/*
* 所有位都为 0 时返回 1, 其他条件下产生 0
* */
int get_result(int x);
int main() {
printf("%d \n", get_result(1));
printf("%d \n", get_result(-1));
printf("%d \n", get_result(0));
printf("%d \n", get_result(25645));
printf("%d \n", get_result(0x73));
return 0;
}
int get_result(int x) {
return !(x ^ 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment