diff options
Diffstat (limited to 'src/util/rational.h')
-rw-r--r-- | src/util/rational.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/util/rational.h b/src/util/rational.h index 53a7e9060..8218984a7 100644 --- a/src/util/rational.h +++ b/src/util/rational.h @@ -75,7 +75,7 @@ public: * For more information about what is a valid rational string, * see GMP's documentation for mpq_set_str(). */ - Rational(const char * s, int base = 10): d_value(s,base) { + explicit Rational(const char * s, int base = 10): d_value(s,base) { d_value.canonicalize(); } Rational(const std::string& s, unsigned base = 10) : d_value(s, base) { @@ -90,6 +90,22 @@ public: } /** + * Constructs a canonical Rational from a numerator. + */ + Rational(signed int n) : d_value(n,1) { + d_value.canonicalize(); + } + Rational(unsigned int n) : d_value(n,1) { + d_value.canonicalize(); + } + Rational(signed long int n) : d_value(n,1) { + d_value.canonicalize(); + } + Rational(unsigned long int n) : d_value(n,1) { + d_value.canonicalize(); + } + + /** * Constructs a canonical Rational from a numerator and denominator. */ Rational(signed int n, signed int d) : d_value(n,d) { |