On Sunday, 27 December 2015 at 16:39:18 UTC, SimonN wrote:
On Sunday, 27 December 2015 at 16:01:37 UTC, TheDGuy wrote:
Sry:
                        if((x1 < 0) & (x2 >= 0)){

This looks like a bug, with & instead of &&.

-- Simon

It looks like the debugger is not working correctly because i changed the code to this:

                if(discriminant > 0){
                        double x1 = (-b - sqrt(discriminant)) / (2.0*a);
                        double x2 = (-b + sqrt(discriminant)) / (2.0*a);
                        if((x1 >= 0) && (x2 >= 0)){
                                return x1;
                        }
                        if((x1 < 0) && (x2 >= 0)){
                                return x2;
                        }
                        return -1.0;
                } else{
                        return -1.0;
                }

and the same problem appears.

Reply via email to