From: fred Date: Sun, 24 Mar 2002 20:07:39 +0000 (+0000) Subject: lilypond-0.1.53 X-Git-Tag: release/1.5.59~3329 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4612a94921a32fda8a0d800052aaf1c751cc6b42;p=lilypond.git lilypond-0.1.53 --- diff --git a/flower/include/rational.hh b/flower/include/rational.hh index 4160af814d..587a7f63f1 100644 --- a/flower/include/rational.hh +++ b/flower/include/rational.hh @@ -34,6 +34,8 @@ public: Rational truncated () const; void negate (); operator bool () const; + operator int () const; + operator double () const; operator String () const; Rational operator - () const; Rational (); diff --git a/flower/rational.cc b/flower/rational.cc index 202dd9f0e7..df18b4cbcd 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -11,12 +11,21 @@ #include "string-convert.hh" #include "libc-extension.hh" - Rational::operator bool () const { return sign_; } +Rational::operator int () const +{ + return sign_ * num_ / den_; +} + +Rational::operator double () const +{ + return (double)sign_ * num_ / den_; +} + ostream & operator << (ostream &o, Rational r) {