## "Fossies" - the Fresh Open Source Software Archive

### Source code changes of the file "Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx" betweencmake-3.13.4.tar.gz and cmake-3.14.0-rc1.tar.gz

About: CMake is a cross-platform build system designed to build, test and package software. Release candidate.

mysqrt.cxx  (cmake-3.13.4):mysqrt.cxx  (cmake-3.14.0-rc1)
#include "MathFunctions.h" #include "MathFunctions.h"
#include "TutorialConfig.h" #include "TutorialConfig.h"
#include <> #include <iostream>
// include the generated table // include the generated table
#include "Table.h" #include "Table.h"
#include <h> #include <cmath>
// a hack square root calculation using simple operations // a hack square root calculation using simple operations
double mysqrt(double x) double mysqrt(double x)
{ {
if (x <= 0) { if (x <= 0) {
return 0; return 0;
} }
// use the table to help find an initial value // use the table to help find an initial value
result = x; double result = x;
if (x >= 1 && x < 10) { if (x >= 1 && x < 10) {
result = sqrtTable[static_cast<int>(x)]; result = sqrtTable[static_cast<int>(x)];
} }
// do ten iterations // do ten iterations
for (int i = 0; i < 10; ++i) {
for = 0; i < 10; ++i) {
if (result <= 0) { if (result <= 0) {
result = 0.1; result = 0.1;
} }
delta = x - (result * result); double delta = x - (result * result);
result = result + 0.5 * delta / result; result = result + 0.5 * delta / result;
; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
} }
return result; return result;
} }
End of changes. 7 change blocks.
12 lines changed or deleted 6 lines changed or added