This is a minor issue that I'm having in a larger program. The program is for factoring a second degree polynomial. The function below is supposed to find the factors, which is does, but let's say a=6, b=1, c=-12 so a*c=-72 and I want the two numbers that will add to 1. Instead of 9 and -8, this code gives me -9 and 8. I can't figure out why. If anyone could help me with this I would really appreciate it.
void findFactors(int a, int b, int c, int&f1, int&f2)
{
int f;
int i=0;
f=-int(sqrt(abs(a*c)));
while(f<=int(sqrt(abs(a*c))))
{
if(f==0)
f++;
if((a*c)%f==0)
{
f1=(a*c)/f, f2=f;
i++;
}
f++;
}
if(f!=-int(sqrt(abs(a*c))))
{
f1==0, f2==0;
}
}