🐛 changed p-q-formula to midnight-formula

main
Isabell Pflug 2 years ago
parent 9770f873de
commit ef7eb5cc66

@ -3,7 +3,7 @@
int check_number(std::string number, double* checked_number) {
std::size_t pos;
*checked_number = std::stoi(number, &pos); // how to properly type check? or is that not necessary?
*checked_number = std::stoi(number, &pos); // how to properly type check?
return 0;
}
@ -18,17 +18,15 @@ int main(int argc, char *argv[]) {
std::cout << "Something went wrong. :/" << std::endl;
return check;
}
double p = b/a;
double q = c/a;
double d = b*b - 4*a*c;
double w = (p*p / 4) - q;
if (w < 0) {
if (d < 0) {
std::cout << "No real solutions." << std::endl;
return 0;
}
double x_1 = -(p / 2) + sqrt(w);
double x_2 = -(p / 2) - sqrt(w);
double x_1 = (-b + sqrt(d))/(2*a);
double x_2 = (-b - sqrt(d))/(2*a);
if (x_1 == x_2)
std::cout << "Double zero at x = " << x_1 << std::endl;

Loading…
Cancel
Save