diff options
-rw-r--r-- | src/algorithms/bits/Signum.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/algorithms/bits/Signum.java b/src/algorithms/bits/Signum.java index 647076c..515e86d 100644 --- a/src/algorithms/bits/Signum.java +++ b/src/algorithms/bits/Signum.java @@ -84,6 +84,18 @@ public class Signum * 1 ^ ((unsigned £{T})value >> (sizeof(£{T}) * CHAR_BITS - 1)) */ } + + /** + * Detect if two integers have opposite signs + * + * @param a One of the integers + * @param b The other of the integers + * @return {@code true} iff either {@code a} or {@code b} is negative and the other is positive + */ + public static boolean haveOpposite(£{T} a, £{T} b) + { + return (x ^ y) < 0; + } £>done } |