]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.5.10
authorfred <fred>
Wed, 27 Mar 2002 01:21:32 +0000 (01:21 +0000)
committerfred <fred>
Wed, 27 Mar 2002 01:21:32 +0000 (01:21 +0000)
VERSION
flower/rational.cc

diff --git a/VERSION b/VERSION
index b3531ee5996c9e847c5ab4a0fda2e83aa09a4274..29adfa84087c3e5e80283415b6a944d5cba830a3 100644 (file)
--- 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
index d5e679a9e973e0711a18ce443986f2ab51e9e9e1..3b0b3d0928da37a1a87c9b2b1f11245d3d5505f4 100644 (file)
@@ -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