Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to do this?
Assuming 32 bit ints:
bool same = ((x ^ y) >> 31) != 1;
Slightly more terse:
bool same = !((x ^ y) >> 31);