The following macro is to determine if two numbers have the same sign, is for 2's complement number representation.
#define SAME_SIGNS( a, b ) (((long) ((unsigned long) a ^ (unsigned long) b)) >= 0 )
Can anyone suggest a javascript equivalent function?