double c = eqn[0]; double b = eqn[1]; double a = eqn[2]; if (a == 0) { if (b == 0) return -1; res[0] = -c / b; return 1; } c /= a; b /= a * 2; double det = Math.sqrt(b * b - c); if (det != det) return 0;  if (b > 0) { res[0] = -b - det; res[1] = -c / (b + det); } else { res[0] = -c / (b - det); res[1] = -b + det; } return 2;
return solveQuadratic(eqn, eqn);
  public static int solveQuadratic(double[] eqn, double[] res)  {    double c = eqn[0];    double b = eqn[1];    double a = eqn[2];    if (a == 0)      {        if (b == 0)          return -1;        res[0] = -c / b;        return 1;      }    c /= a;    b /= a * 2;    double det = Math.sqrt(b * b - c);    if (det != det)      return 0;    // For fewer rounding errors, we calculate the two roots differently.    if (b > 0)      {        res[0] = -b - det;        res[1] = -c / (b + det);      }    else      {        res[0] = -c / (b - det);        res[1] = -b + det;      }    return 2;  }