rational.hh File Reference

Interface for class rational. More...

#include <iostream>
Include dependency graph for rational.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


class  rational
 The class rational represents rational number. More...


#define RCMP(OP)
 Common pattern for rational comparisons.


std::ostream & operator<< (std::ostream &out, const rational &rat)
 Print a rational number to an output stream.

Detailed Description

Interface for class rational.

Definition in file rational.hh.

Define Documentation

#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.

Function Documentation

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.
a reference to the output stream.

Definition at line 41 of file rational.cc.

References rational::denom, and rational::nom.

Generated on Fri Aug 21 08:15:08 2009 for mqn2mps by  doxygen 1.6.0