Parham has asked for the wisdom of the Perl Monks concerning the following question:
i ran into the problem where my program would sometimes be forced to take negative square roots. I tried to catch an error somewhere in the function, but couldn't do so.
I've tried the following:
andeval { $number = sqrt(-1) }; if ($@) { print "negative sqrt"; }
and$number = sqrt(-1) or die "error";
all with no luck. Math::Complex manages to take negative squareroots, but i didn't wanna bother doing that. The only good solution i can come up with right now is checking for a negative number before performing the function. Any ideas on alternatives?$number = sqrt(-1) or print "error";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: negative sqrt()
by Fletch (Bishop) on Feb 09, 2002 at 16:04 UTC | |
(jeffa) Re: negative sqrt()
by jeffa (Bishop) on Feb 09, 2002 at 15:48 UTC |
Back to
Seekers of Perl Wisdom