diff options
Diffstat (limited to 'src/util/rational_gmp_imp.h')
-rw-r--r-- | src/util/rational_gmp_imp.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h index 95a15bc5a..ed9c57a80 100644 --- a/src/util/rational_gmp_imp.h +++ b/src/util/rational_gmp_imp.h @@ -62,7 +62,8 @@ private: public: - /** Creates a rational from a decimal string (e.g., <code>"1.5"</code>). + /** + * Creates a rational from a decimal string (e.g., <code>"1.5"</code>). * * @param dec a string encoding a decimal number in the format * <code>[0-9]*\.[0-9]*</code> @@ -155,6 +156,15 @@ public: return Integer(d_value.get_den()); } + /** + * Get a double representation of this Rational, which is + * approximate: truncation may occur, overflow may result in + * infinity, and underflow may result in zero. + */ + double getDouble() const { + return d_value.get_d(); + } + Rational inverse() const { return Rational(getDenominator(), getNumerator()); } |