Elements
6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ElementsExamples
src
lib
default
PiCalculator.cpp
Go to the documentation of this file.
1
18
#include "
ElementsExamples/PiCalculator.h
"
19
20
namespace
Elements
{
21
namespace
Examples {
22
23
void
PiCalculator::calculate
(
unsigned
int
terms) {
24
25
double
pi = 0.0;
26
// Leibniz formula for pi
27
double
numerator = -1.0;
28
double
denominator = -1.0;
29
30
for
(
unsigned
int
ii = 0; ii < terms; ++ii) {
31
numerator *= -1;
32
denominator += 2.0;
33
pi += numerator / denominator;
34
}
35
36
pi *= 4.0;
37
38
m_show_result_callback
(pi);
39
}
40
41
void
PiCalculator::setShowResultCallback
(show_result_callback_type f) {
42
43
m_show_result_callback
= f;
44
}
45
46
}
// namespace Examples
47
}
// namespace Elements
PiCalculator.h
Elements::Examples::PiCalculator::m_show_result_callback
show_result_callback_type m_show_result_callback
Definition:
PiCalculator.h:41
Elements::Examples::PiCalculator::calculate
void calculate(unsigned int terms)
Definition:
PiCalculator.cpp:23
Elements::Examples::PiCalculator::setShowResultCallback
void setShowResultCallback(show_result_callback_type f)
Definition:
PiCalculator.cpp:41
Elements
Definition:
callBackExample.h:35
Generated by
1.9.6