formatting
This commit is contained in:
parent
e972fd631e
commit
2d43ed3eda
1 changed files with 2 additions and 2 deletions
|
@ -1394,11 +1394,11 @@ import std.stdio : writeln;
|
||||||
auto sqrt(T)(T x) {
|
auto sqrt(T)(T x) {
|
||||||
enum GoodEnough = 0.01;
|
enum GoodEnough = 0.01;
|
||||||
import std.math : abs;
|
import std.math : abs;
|
||||||
T z = x*x, old = 0;
|
T z = x * x, old = 0;
|
||||||
int iter;
|
int iter;
|
||||||
while (abs(z - old) > GoodEnough) {
|
while (abs(z - old) > GoodEnough) {
|
||||||
old = z;
|
old = z;
|
||||||
z -= ((z*z)-x) / (2*z);
|
z -= ((z * z) - x) / (2 * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return z;
|
return z;
|
||||||
|
|
Loading…
Reference in a new issue