Elements  5.10
A C++ base framework for the Euclid Software.
PiCalculator.cpp
Go to the documentation of this file.
1 
20 
21 namespace Elements {
22 namespace Examples {
23 
24 void PiCalculator::calculate(unsigned int terms) {
25 
26  double pi = 0.0;
27  // Leibniz formula for pi
28  double numerator = -1.0;
29  double denominator = -1.0;
30 
31  for (unsigned int ii = 0; ii < terms; ++ii) {
32  numerator *= -1;
33  denominator += 2.0;
34  pi += numerator / denominator;
35  }
36 
37  pi *= 4.0;
38 
40 
41 }
42 
43 void PiCalculator::setShowResultCallback(show_result_callback_type f) {
44 
46 
47 }
48 
49 
50 } // namespace Examples
51 } // namespace Elements
constexpr double pi
Definition: MathConstants.h:33
void setShowResultCallback(show_result_callback_type f)
void calculate(unsigned int terms)
show_result_callback_type m_show_result_callback
Definition: PiCalculator.h:41