Finding square root without using sqrt function?
There is a better algorithm, which needs at most 6 iterations to converge to maximum precision for double numbers: #include <math.h> double sqrt(double x) { if (x <= 0) return 0; // if negative number throw an exception? int exp = 0; x = frexp(x, &exp); // extract binary exponent from x if (exp & … Read more