I am trying to write a program to solve a quadratic equation whose coefficients\' values do not exceed 100 by absolute value and it is guaranteed that if any roots exist, they a
The way to fix this is to static_cast
because long long is 8 bytes and it is large enough to hold the information in the event of an overflow. An overflow occurs when you try to hold a number when you do not have enough bits to do so and as a result some of them get chopped off.
Here is an example without the warning:
std::cout << "Two roots: " << (-b - std::sqrt(d)) / (2 * static_cast(a)) << " "
<< (-b + std::sqrt(d)) / (2 * static_cast(a));