From: fred Date: Wed, 27 Mar 2002 01:21:32 +0000 (+0000) Subject: lilypond-1.5.10 X-Git-Tag: release/1.5.59~545 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=48238a8b15e6d6dc19f75ea230d97507cbca737c;p=lilypond.git lilypond-1.5.10 --- diff --git a/VERSION b/VERSION index b3531ee599..29adfa8408 100644 --- a/VERSION +++ b/VERSION @@ -1,7 +1,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 -PATCH_LEVEL=9 +PATCH_LEVEL=10 MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a diff --git a/flower/rational.cc b/flower/rational.cc index d5e679a9e9..3b0b3d0928 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -44,6 +44,13 @@ Rational::Rational (int n, int d) normalise (); } +Rational::Rational (int n) +{ + sign_ = ::sign (n); + num_ = abs (n); + den_= 1; +} + static int gcd (int a, int b) { @@ -99,31 +106,31 @@ Rational::normalise () { den_ = 1; num_ = 0; - return ; } - if (!den_) - sign_ = 2; - if (!num_) - sign_ = 0; - - int g = gcd (num_ , den_); + else if (!den_) + { + sign_ = 2; + num_ = 1; + } + else if (!num_) + { + sign_ = 0; + den_ = 1; + } + else + { + int g = gcd (num_ , den_); - num_ /= g; - den_ /= g; + num_ /= g; + den_ /= g; + } } - int Rational::sign () const { return ::sign (sign_); } -bool -Rational::infty_b () const -{ - return abs (sign_) > 1; -} - int Rational::compare (Rational const &r, Rational const &s) { @@ -133,8 +140,17 @@ Rational::compare (Rational const &r, Rational const &s) return 1; else if (r.infty_b ()) return 0; - - return (r - s).sign (); + else if (r.sign_ == 0) + return 0; + else + { + /* + TODO: fix this code; (r-s).sign() is too expensive. + + return r.sign_ * ::sign (r.num_ * s.den_ - s.num_ * r.den_); + */ + return (r - s).sign (); + } } int