I was just curious I have this piece of Java code. My question is what is the reason to return 1.0 * the recursive call? in the else portion of the code
My 2nd question is when I declare the E variable as 0.0000001 AND A , X variables as doubles in my main portion of the code I make the A as 0 and go into an infinite loop. How do I solve this?
public static double sqrtR(long x, double e, double a) {
if (Math.abs(a * a - x) <= e) {
return a;
} else {
a = (a * a + x) / (2 * a);
return 1.0 * (sqrtR(x, e, a));
}
}