update ft_sqrt with precision
This commit is contained in:
@@ -4,17 +4,13 @@
|
||||
* return the square root of nb
|
||||
* Newton–Raphson method : https://en.wikipedia.org/wiki/Newton%27s_method#Use_of_Newton's_method_to_compute_square_roots
|
||||
*/
|
||||
double ft_sqrt(double x)
|
||||
double ft_sqrt(double x, double precision)
|
||||
{
|
||||
double precision;
|
||||
|
||||
if (x < 0)
|
||||
return -1; // handle negative numbers
|
||||
if (x == 0)
|
||||
return 0;
|
||||
|
||||
precision = 0.00001;
|
||||
|
||||
// Newton-Raphson
|
||||
double guess = x;
|
||||
double prev_guess;
|
||||
|
||||
Reference in New Issue
Block a user