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.
In reply to Re^2: solving a quadratic equation
by SuicideJunkie
in thread solving a quadratic equation
by vis1982
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |