Fraction.h
Go to the documentation of this file.
1 #ifndef art_test_Integration_product_aggregation_physics_workflow_Fraction_h
2 #define art_test_Integration_product_aggregation_physics_workflow_Fraction_h
3 
4 namespace arttest {
5 
6  class Fraction {
7  public:
8  Fraction() = default;
9 
10  Fraction(unsigned const num, unsigned const denom)
11  : num_{num}, denom_{denom}
12  {}
13 
14  double
15  value() const
16  {
17  return denom_ == 0. ? 0. : static_cast<double>(num_) / denom_;
18  }
19 
20  double
21  numerator() const
22  {
23  return num_;
24  }
25 
26  void
28  {
29  num_ += f.num_;
30  denom_ += f.denom_;
31  }
32 
33  private:
34  unsigned num_{-1u};
35  unsigned denom_{-1u};
36  };
37 
38 } // namespace arttest
39 
40 #endif /* art_test_Integration_product_aggregation_physics_workflow_Fraction_h */
41 
42 // Local variables:
43 // mode: c++
44 // End:
Fraction()=default
Fraction(unsigned const num, unsigned const denom)
Definition: Fraction.h:10
unsigned denom_
Definition: Fraction.h:35
unsigned num_
Definition: Fraction.h:34
void aggregate(Fraction const &f)
Definition: Fraction.h:27
double numerator() const
Definition: Fraction.h:21
double value() const
Definition: Fraction.h:15