in reply to Re: Seeing if two numbers have the same sign
in thread Seeing if two numbers have the same sign

Neat (wish I'd thought of it) but it implicitly assumes that zero is a positive number, given 0 and -1 the test returns 0, given 0 and +1 it returns 1. If the test was ( $x<=0 == $y<=0 ) then zero is treated as both positive and negative and the two previous examples return 1. Which is consistent but might not be what you want.

Replies are listed 'Best First'.
Re^3: Seeing if two numbers have the same sign
by graff (Chancellor) on Jan 12, 2008 at 17:48 UTC
    Maybe I'm just old-fashioned (primitive?), but my understanding of the term "same sign", at least as it relates to programming, has always been: when the sign bit of two values is the same, those values have "the same sign". In that interpretation, zero is always included among the set of "non-negative" values: it is the same sign as "1", and not the same sign as "-1".