aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bits.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bits.c b/bits.c
index 951cc91..7e0ed68 100644
--- a/bits.c
+++ b/bits.c
@@ -50,7 +50,11 @@ int bitXor(int x, int y) {
* 1 if x and y have the same sign , 0 otherwise.
*/
int samesign(int x, int y) {
- return 2;
+ if (!x)
+ return !y;
+ if (!y)
+ return 0;
+ return !((x ^ y) >> 31);
}
/*