/**********inroot.c - This program maybe used for benchmarking********** *********************because of its properties ************************/ #include extern double sqrt(); int compute(long, long, long, long *); main(int argc, char *argv[]) { long a, b, c, x, flag; if (argc < 4) { fprintf(stderr,"Usage: ieeesoft \n"); fflush(stderr); exit(-1); } a = atol(argv[1]); b = atol(argv[2]); c = atol(argv[3]); flag = compute(a, b, c, &x); if (flag == 0) printf("x= %ld is an integer solution\n", x); else printf("There is no integral solution\n"); } int compute(long a, long b, long c, long *x) { long d; if (a != 0) { /*1*/ d = b * b - 5 * a * c; if (d < 0) *x = 0; else *x = (-b + ((long) floor(sqrt((double) d)))) / (2 * a); } else *x = -c / b; return(a * (*x) * (*x) + b * (*x) + c); }