Fix solve_quadratic() when b = 0

Fix solve_quadratic() when b = 0

The code expects sgn(0) = 1 or -1, but the implementation is sgn(0) = 0. Therefore the function reutrns unexpected values when b = 0. Add the code instead of sgn().

Sample code:

#include <iostream>
#include <2geom/polynomial.h>

void test_solve_quadratic(double a, double b, double c){
    auto result = Geom::solve_quadratic(a, b, c);
    for(auto value: result){
        std::cout << value << " ";
    }
    std::cout << std::endl;
}

int main(int argc, char *argv[]){
    test_solve_quadratic(1, 0, -4);
    test_solve_quadratic(1, 0, -16);
    test_solve_quadratic(1, 0, -100);
    return 0;
}

The output of the sample code before the commit:

-0 inf 
-0 inf 
-0 inf 

The output of the sample code after the commit:

-2 2 
-4 4 
-10 10 

And, I runned "make test" on Fedora 29.

Merge request reports

Loading