in reply to Re: solving a quadratic equation
in thread solving a quadratic equation
Ambrus: Why does your choice of root depend on the sign of $b?
Returning a list containing both roots is quite reasonable for Perl, and then the calling function can decide what subset of them it wants to use.
I would also suggest a test for $a being too small, and then use a linear solution rather than trying to divide by zero.
|
|---|