Elements  6.0.1
A C++ base framework for the Euclid Software.
PiCalculator.cpp
Go to the documentation of this file.
1 
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 
39 }
40 
41 void PiCalculator::setShowResultCallback(show_result_callback_type f) {
42 
44 }
45 
46 } // namespace Examples
47 } // namespace Elements
show_result_callback_type m_show_result_callback
Definition: PiCalculator.h:41
void calculate(unsigned int terms)
void setShowResultCallback(show_result_callback_type f)
constexpr double pi
Definition: MathConstants.h:34