diff options
author | Michael Abed <michaelabed@gmail.com> | 2012-03-03 23:32:27 -0500 |
---|---|---|
committer | Michael Abed <michaelabed@gmail.com> | 2012-03-03 23:32:27 -0500 |
commit | f2566da91396bc07356601794fd5db858a78f1f3 (patch) | |
tree | 6d18e7e9a517163dee5929eef6617cce12cfb415 /mysqrt.cpp | |
parent | 12993b517ff2f8ec6608c2deaf3e988c64f7f164 (diff) | |
download | ec327-lab2-f2566da91396bc07356601794fd5db858a78f1f3.tar.gz ec327-lab2-f2566da91396bc07356601794fd5db858a78f1f3.tar.bz2 ec327-lab2-f2566da91396bc07356601794fd5db858a78f1f3.zip |
make basically everything work
Diffstat (limited to 'mysqrt.cpp')
-rw-r--r-- | mysqrt.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -7,7 +7,7 @@ double mysqrt(double x) bool goodenough = false; double lastGuess, nextGuess; - lastGuess = x / 10.0; + lastGuess = x / 2; if (x <= 0) return x; @@ -15,9 +15,9 @@ double mysqrt(double x) while (!goodenough) { nextGuess = (lastGuess + (x / lastGuess)) / 2.0; + goodenough = abs(nextGuess - lastGuess) <= 0.00001; lastGuess = nextGuess; - goodenough = abs(nextGuess - lastGuess) <= 0.000000000001; } return nextGuess; } |