1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 08:51:52 +08:00

Help/guide/tutorial: Adopt tutorial code

This commit is contained in:
Kitware Robot
2019-05-30 12:41:21 -04:00
committed by Betsy McPhail
parent d2fde94809
commit 862cfc0e6c
123 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
#include "MathFunctions.h"
#include <iostream>
// a hack square root calculation using simple operations
double mysqrt(double x)
{
if (x <= 0) {
return 0;
}
double result = x;
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
result = 0.1;
}
double delta = x - (result * result);
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
return result;
}