aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk3/lab3/RootBabylonOG.cpp
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2019-02-20 16:00:41 -0600
committerMatthew Strapp <msattr@gmail.com>2019-02-20 16:00:41 -0600
commit93ff5f30e854390dc6bb790414e13986144514fa (patch)
tree3ae048da5dfafaa05f6573fd8a29a402a38a0470 /ee1301/wk3/lab3/RootBabylonOG.cpp
parent(Screams internally) (diff)
downloadhomework-93ff5f30e854390dc6bb790414e13986144514fa.tar
homework-93ff5f30e854390dc6bb790414e13986144514fa.tar.gz
homework-93ff5f30e854390dc6bb790414e13986144514fa.tar.bz2
homework-93ff5f30e854390dc6bb790414e13986144514fa.tar.lz
homework-93ff5f30e854390dc6bb790414e13986144514fa.tar.xz
homework-93ff5f30e854390dc6bb790414e13986144514fa.tar.zst
homework-93ff5f30e854390dc6bb790414e13986144514fa.zip
Finish Lab 3
Diffstat (limited to '')
-rw-r--r--ee1301/wk3/lab3/RootBabylonOG.cpp (renamed from ee1301/wk3/lab3/RtBab.cpp)10
1 files changed, 3 insertions, 7 deletions
diff --git a/ee1301/wk3/lab3/RtBab.cpp b/ee1301/wk3/lab3/RootBabylonOG.cpp
index d75bd9e..07c1951 100644
--- a/ee1301/wk3/lab3/RtBab.cpp
+++ b/ee1301/wk3/lab3/RootBabylonOG.cpp
@@ -3,15 +3,11 @@
using namespace std;
double gennewGuess(double n, double old_guess) {
- bool WA=true;
double real, old;
- //if (WA) {
- real=sqrt(n);
- WA=false;
- //}
+ real=sqrt(n);
double new_guess = ( old_guess + n / old_guess ) / 2;
old=new_guess;
- if (((new_guess-real)/real)>0.01) {
+ if (((new_guess-real)/real)>0.01) { //This will be true if the difference between the real root and guess is more than 1%.
cout << old << endl;
return gennewGuess(n, old);
} else {
@@ -25,7 +21,7 @@ int main () {
cin >> temp;
if (temp<=0) {
cout << "Please enter a valid input(Positive Integer)." << endl;
- return -1;
+ return sqrt(-1);
}
cout << "Guessing..." << endl;
double real=sqrt(temp);