]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/rational.cc
*** empty log message ***
[lilypond.git] / flower / rational.cc
index 11aaf1e23b6ce457df53985ca52e62e7143d7708..c5019afbd5a5d1fa6563a461e024ced7df70d21c 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the Flower Library
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include <math.h>
 #include <stdlib.h>
@@ -17,12 +17,15 @@ Rational::operator double () const
   return (double)sign_ * num_ / den_;
 }
 
+#ifdef STREAM_SUPPORT
 ostream &
 operator << (ostream &o, Rational r)
 {
-  o <<  r.str ();
+  o <<  r.string ();
   return o;
 }
+#endif
+
 
 Rational
 Rational::trunc_rat () const
@@ -63,11 +66,13 @@ int gcd (int a, int b)
   return b;
 }
 
+#if 0
 static
 int lcm (int a, int b)
 {
   return abs (a*b / gcd (a,b));
 }
+#endif
 
 void
 Rational::set_infinite (int s)
@@ -144,12 +149,7 @@ Rational::compare (Rational const &r, Rational const &s)
     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 ();
+      return r.sign_ * ::sign  (int (r.num_ * s.den_) - int (s.num_ * r.den_));
     }
 }
 
@@ -276,27 +276,18 @@ Rational::operator -= (Rational r)
   return (*this += r);
 }
 
-/*
-  be paranoid about overiding libg++ stuff
- */
-Rational &
-Rational::operator = (Rational const &r)
-{
-  copy (r);
-  return *this;
-}
-
 String
-Rational::str () const
+Rational::to_string () const
 {
   if (infty_b ())
     {
       String s (sign_ > 0 ? "" : "-" );
       return String (s + "infinity");
     }
-  String s = to_str (num ());
+
+  String s = ::to_string (num ());
   if (den () != 1 && num ())
-    s += "/" + to_str (den ());
+    s += "/" + ::to_string (den ());
   return s;
 }