Negative integers
Vlastimil Brom
vlastimil.brom at gmail.com
Wed Aug 20 17:55:42 EDT 2008
2008/8/20 johnewing <john.ewi at gmail.com>
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>
What about a straightforward approach like:
(a < 0 and b < 0) or (a >= 0 and b >= 0)
Probably there are some more sophisticated/elegant ... ones.
Vlasta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080820/3149e290/attachment-0001.html>
More information about the Python-list
mailing list