From: Jan Nieuwenhuizen Date: Mon, 27 Apr 1998 05:46:23 +0000 (-0400) Subject: patch::: 0.1.48: Re: lily 0.1.59 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=07ef2535c467fd25ed35ebdc53fde1d63d6323ec;p=lilypond.git patch::: 0.1.48: Re: lily 0.1.59 --- 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) {