Negative integers

nntpman68 news1234 at free.fr
Wed Aug 20 18:01:47 EDT 2008


Hm,


It seems my previous reply got lost.


if a*b > 0:
	print "same sign"
else
	print "different sign"


johnewing wrote:
> I am trying to figure out how to test if two numbers are of the same
> sign (both positive or both negative).  I have tried
> 
> abs(x) / x == abs(y) / y
> 
> but that fails when one of the numbers is 0.  I'm sure that there is
> an easy way to do this.  Any suggestions?
> 
> Thanks



More information about the Python-list mailing list