Check if two numbers have opposite signs?
public bool HaveOppositeSigns(int x, int y) {
return (x ^ y) < 0;
Explanation:
XOR of two numbers with opposite signs has the sign bit set (negative number).
public bool HaveOppositeSigns(int x, int y) {
return (x ^ y) < 0;
Explanation:
XOR of two numbers with opposite signs has the sign bit set (negative number).