1. Detect if two integers have opposite signs
int x, y; // two integers
bool f=((x^y)<0 ); //true if x and y have opposite signs
http://www-graphics.stanford.edu/~seander/bithacks.html
本文介绍了一种使用位操作判断两个整数是否符号相反的方法。通过异或运算与小于零的比较,可以高效地判断出两个整数的符号是否相对。这种方法在计算机科学中特别有用,尤其是在需要快速进行符号比较的场景下。
1. Detect if two integers have opposite signs
int x, y; // two integers
bool f=((x^y)<0 ); //true if x and y have opposite signs
http://www-graphics.stanford.edu/~seander/bithacks.html

被折叠的 条评论
为什么被折叠?