X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fmath%2Fsqrt.c;h=7dd60203519089a8e5adc7e16a521813e14610ce;hb=e081ed1387e0c27dc689c8e32fdda06039544107;hp=3c6c1266f020b612c0e0c30efbedb2c1c5600ad1;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/math/sqrt.c b/functions/math/sqrt.c index 3c6c126..7dd6020 100644 --- a/functions/math/sqrt.c +++ b/functions/math/sqrt.c @@ -5,15 +5,23 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// C++ +double sqrt( double x ) { /* TODO */ }; -float sqrt( float x ) { /* TODO */ }; -long double sqrt( long double x ) { /* TODO */ }; +/* Therx code +{ + double i = x / 2; + if ( x < 0 ) + { + return 0; + } + // (15 DP) HOW GET MORE? + while ( ( fabs( i - ( x / i ) ) / i ) > 0.000000000000001) + { + i = ( i + ( x / i ) ) / 2; + } + return i; +} +*/ -// ---------------------------------------------------------------------------- -// Standard C - -double sqrt( double x ) { /* TODO */ }; float sqrtf( float x ) { /* TODO */ }; long double sqrtl( long double x ) { /* TODO */ };