What would be the hardest way in Java to check the following condition
int m, n;
The test condition is whether m or n are negative, but both of them should not be negative. I am looking for simple but simple syntax
(m < 0) ^ (n < 0)
Note that in this context ^ is a logical XOR operator (yes, I mean "logical" other than "bitwise").
^
(m ^ n) < 0
Even more placeholder to respond to the appropriate length.
I would go for:
(m < 0) != (n < 0)
!= works the same as ^ for boolean s, but I think it is easier to understand and use more often.
!=
boolean
Basically your test should be - the sign bit (highest order) will be different.
Here is a test expressed in java;
if ( (x & Integer.MIN_VALUE) != (y & Integer.MIN_VALUE) ) ...