Interface for class rational. More...
#include <iostream>
Go to the source code of this file.
Classes | |
class | rational |
The class rational represents rational number. More... | |
Defines | |
#define | RCMP(OP) |
Common pattern for rational comparisons. | |
Functions | |
std::ostream & | operator<< (std::ostream &out, const rational &rat) |
Print a rational number to an output stream. |
Interface for class rational.
Definition in file rational.hh.
#define RCMP | ( | OP | ) |
bool operator OP (const rational& other) const \ { return nom * other.denom OP denom * other.nom; }
Common pattern for rational comparisons.
Each comparison operator is implemented by a comparison of the crosswise multiplication of both sides, as given by the expansion of this macro.
OP | the comparison operator to be implemented. |
Definition at line 92 of file rational.hh.
std::ostream& operator<< | ( | std::ostream & | out, | |
const rational & | rat | |||
) |
Print a rational number to an output stream.
A nominator of one will be omitted.
out | the stream to which the number is written. | |
rat | the rational number to be printed. |
Definition at line 41 of file rational.cc.
References rational::denom, and rational::nom.