2 rational.hh -- declare rational helpers
4 source file of the Flower Library
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
15 #define Rational MyRational
20 #include "arithmetic-operator.hh"
25 unsigned int num_, den_;
27 void copy (Rational const &);
29 void set_infinite (int sign);
30 bool infty_b () const;
32 int num () const { return sign_ * num_; }
33 int den () const { return den_; }
34 Rational truncated () const;
36 operator bool () const;
37 operator String () const;
38 Rational operator - () const;
40 Rational (int, int =1);
42 Rational (Rational const&);
44 Rational &operator = (Rational const &);
45 Rational &operator *= (Rational);
46 Rational &operator /= (Rational);
47 Rational &operator += (Rational);
48 Rational &operator -= (Rational);
49 static int compare (Rational const&, Rational const&);
54 IMPLEMENT_ARITHMETIC_OPERATOR (Rational, / );
55 IMPLEMENT_ARITHMETIC_OPERATOR (Rational, + );
56 IMPLEMENT_ARITHMETIC_OPERATOR (Rational, * );
57 IMPLEMENT_ARITHMETIC_OPERATOR (Rational, - );
59 INSTANTIATE_COMPARE (Rational const&, Rational::compare);
61 int compare (Rational const&,Rational const&);
62 int sign (Rational r);
65 Rational::copy (Rational const&r)
74 operator << (ostream &, Rational);