source file of the Flower Library
- (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#ifndef RATIONAL_HH
#define RATIONAL_HH
-#include "compare.hh"
-#include "arithmetic-operator.hh"
-#include "flower-proto.hh"
#include "string.hh"
-
/**
Rational numbers. Included is support for + and - infinity.
*/
public:
void set_infinite (int sign);
- bool infty_b () const
- {
- return sign_ == 2 || sign_ == -2;
- }
+ bool is_infinity () const;
void invert ();
- int num () const { return sign_ * num_; }
- int den () const { return den_; }
+ int numerator () const { return sign_ * num_; }
+ int denominator () const { return den_; }
+ int num () const { return numerator(); }
+ int den () const { return denominator(); }
Rational trunc_rat () const;
Rational div_rat (Rational) const;
Rational &operator %= (Rational);
static int compare (Rational const&, Rational const&);
int sign () const;
- String str () const;
+ String to_string () const;
};
IMPLEMENT_ARITHMETIC_OPERATOR (Rational, / );
den_ = r.den_;
}
+#if 0
ostream &
operator << (ostream &, Rational);
+#endif
const Rational infinity_rat = INT_MAX;