Public Methods |
| EkRational (void) |
| Default constructor. More...
|
| EkRational (const Type &numer, const Type &denom) |
| constructor. More...
|
| EkRational (const EkRational< Type > &theSrc) |
| constructor. More...
|
| ~EkRational (void) |
| This is the destructor. More...
|
EkRational< Type > & | operator= (const EkRational< Type > &rhs) |
| This is an operator equals. More...
|
EkRational< Type > & | operator+= (const EkRational< Type > &rhs) |
| This is an operator+=. More...
|
EkRational< Type > & | operator-= (const EkRational< Type > &rhs) |
| This is an operator-=. More...
|
EkRational< Type > & | operator *= (const EkRational< Type > &rhs) |
| This is an operator *=. More...
|
EkRational< Type > & | operator/= (const EkRational< Type > &rhs) |
| This is an operator/=. More...
|
bool | operator== (const EkRational< Type > &rhs) const |
| This is an operator==. More...
|
bool | operator!= (const EkRational< Type > &rhs) const |
| This is an operator!=. More...
|
bool | operator< (const EkRational< Type > &rhs) const |
| This is an operator<. More...
|
bool | operator<= (const EkRational< Type > &rhs) const |
| This is an operator<=. More...
|
bool | operator> (const EkRational< Type > &rhs) const |
| This is an operator>. More...
|
bool | operator>= (const EkRational< Type > &rhs) const |
| This is an operator>=. More...
|
double | asDouble (void) const |
| This converts the rational to a double. More...
|
ostream & | print (ostream &os) const |
| This prints to the stream. More...
|
istream & | read (istream &is) |
| This reads from the stream. More...
|
double | rationalize (const double &mFpVal, const double error=1.0e-10) |
| Convert a floating point number into a rational. More...
|
const Type & | numerator (void) const |
| Access the numerator of the rational. More...
|
const Type & | denominator (void) const |
| Access the denominator of the rational. More...
|
void | numerator (const Type &numer) |
| This method sets the numerator. More...
|
void | denominator (const Type &denom) |
| This mehtod sets the denominator. More...
|
A rational number is a fraction, p/q, where p and q are integers, with p being the Numerator and q the Denominator. This class can be constructed in several ways. First, using the constructor that takes two intergers the numerator and denominator. Second, using the default constructor and later supplying the numerator and denominator through class methods. Lastly, using the default constructor and supplying a floating point number to the rationalize() method that inturn calculates the integer numerator and denominator to the given precision (default is 1E-10). Smart pointers to the long and unsigned long versions of the EkRational class are pre-defined in the header file.