sub same_sign { my ($x,$y) = @_; if ( undef($x) or undef($y)) { return 0; # "undef" is never same-sign } if ( ( ($x >= 0) and ($y >= 0) ) or ( ($x < 0) and ($y < 0) ) ) { return 1; } else { return 0; } }