Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to make a square root function in c++ without stl

double sqrt(double number)
{
    double error = 0.00001; //define the precision of your result
    double s = number;

    while ((s - number / s) > error) //loop until precision satisfied 
    {
        s = (s + number / s) / 2;
    }
    return s;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #square #root #function #stl
ADD COMMENT
Topic
Name
8+5 =