From 07ef2535c467fd25ed35ebdc53fde1d63d6323ec Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 27 Apr 1998 01:46:23 -0400 Subject: [PATCH] patch::: 0.1.48: Re: lily 0.1.59 --- flower/include/rational.hh | 2 ++ flower/rational.cc | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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) { -- 2.39.2