OSB_LIB::Fraction Class Reference

Collaboration diagram for OSB_LIB::Fraction:

Collaboration graph
List of all members.

Detailed Description

Fractions without rounding error.

The class Fraction models a mathematical fraction.
The following invariants are always maintained:

Definition at line 61 of file fraction.h.

Public Member Functions

Private Member Functions

Private Attributes

Constructor & Destructor Documentation

OSB_LIB::Fraction::Fraction (  )  [inline]

Default constructor: sets value to 0.

Definition at line 64 of file fraction.h.

OSB_LIB::Fraction::Fraction ( long  nominator,
long  denominator = 1 

Constructor with nominator and optional denominator.

Member Function Documentation

double OSB_LIB::Fraction::dbl (  )  const [inline]

Convert to double.

Definition at line 78 of file fraction.h.

References denominator_, and nominator_.

long OSB_LIB::Fraction::denominator (  )  const [inline]

Get the denominator.

Definition at line 76 of file fraction.h.

References denominator_.

Referenced by OSB_LIB::operator==().

void OSB_LIB::Fraction::divide ( long higher,
long lower 
) [private]

Used by reduce(...).

long OSB_LIB::Fraction::nominator (  )  const [inline]

Get the nominator.

Definition at line 74 of file fraction.h.

References nominator_.

Referenced by OSB_LIB::operator==().

Fraction& OSB_LIB::Fraction::operator *= ( const Fraction  ) 


Fraction& OSB_LIB::Fraction::operator+= ( const Fraction  ) 


Fraction & OSB_LIB::Fraction::operator- (  )  [inline]

Change the sign of the fraction.

Definition at line 136 of file fraction.h.

References nominator_.

Fraction& OSB_LIB::Fraction::operator-= ( const Fraction  ) 


Fraction& OSB_LIB::Fraction::operator/= ( const Fraction  ) 


void OSB_LIB::Fraction::reduce (  )  [private]

Reduce the fraction to its lowest term.

std::string OSB_LIB::Fraction::str (  )  const

Convert to string: n/d.

Member Data Documentation

long OSB_LIB::Fraction::denominator_ [private]

The denominator of the fraction.

Definition at line 109 of file fraction.h.

Referenced by dbl(), and denominator().

long OSB_LIB::Fraction::nominator_ [private]

The nominator of the fraction.

Definition at line 107 of file fraction.h.

Referenced by dbl(), nominator(), and operator-().

The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:11:18 2006 for OSB Library by  doxygen 1.4.7