![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Seeing if two numbers have the same signby demerphq (Chancellor) |
on Jan 10, 2008 at 18:55 UTC ( #661703=note: print w/replies, xml ) | Need Help?? |
You are doing more work than you need to. Remember that mathematical comparisons return booleans, and booleans can be directly compared.
(($x ^ $y) < 0) would probably also work assuming they are integers. I think the trick with abs or the comparison operator would probably actually be less efficient than doing a comparison. Using multiplication is going to be slow as well. BTW the sign of zero isnt a theological debate, it is an implementation detail of the machine you are working on and the data types you are using. :-)
--- $world=~s/war/peace/g
In Section
Seekers of Perl Wisdom
|
|