Loading [MathJax]/extensions/tex2jax.js
hej is hosted by Hepforge, IPPP Durham
HEJ  2.3.0
High energy resummation for hadron colliders
Fraction.hh
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <stdexcept>
11 #include <string>
12 #include <type_traits>
13 
14 namespace HEJ {
15 
17  template<
18  class Real,
19  typename = std::enable_if_t<std::is_floating_point<Real>::value>
20  >
21  class Fraction {
22  public:
23  Fraction() = default;
24 
25  explicit Fraction(Real r): f_{r} {
26  if(f_ < 0 || f_ > 1) {
27  throw std::invalid_argument{
28  std::to_string(f_) + " is not between 0 and 1"
29  };
30  }
31  }
32 
33  Fraction & operator=(Real r) {
34  f_ = Fraction{r};
35  return *this;
36  }
37 
38  operator Real() const {
39  return f_;
40  }
41 
42  private:
43  Real f_;
44  };
45 } // namespace HEJ
Class for floating point numbers between 0 and 1.
Definition: Fraction.hh:21
Fraction()=default
Fraction & operator=(Real r)
Definition: Fraction.hh:33
Fraction(Real r)
Definition: Fraction.hh:25
Main HEJ 2 Namespace.
Definition: mainpage.dox:1
std::string to_string(Event const &ev)