#include <Rational.h>
Public Member Functions | |
| Rational () | |
| Default constructor. | |
| Rational (Integer i) | |
| Default constructor. | |
| Rational (Const Rational &x) | |
| Copy constructor. | |
| Rational (Real x) | |
| Construct Rational given a fractional value. | |
| Rational (Integer num, Integer den) | |
| Construct Rational given a rational fraction value. | |
| Rational (Real x, Integer &num, Integer &den) | |
| Construct Rational given a Real fractional value, determine its rational approximation, assign numerator and denominator to reference arguments. | |
| Rational (Rational x, Integer &num, Integer &den) | |
| Construct Rational given a Rational, determine its rational approximation, assign numerator and denominator to reference arguments. | |
| Rational & | operator= (Const Rational &x) |
| Rational assignment operator. | |
| Bool | operator== (Const Rational &x) Const |
| Rational equality operator. | |
| Bool | operator!= (Const Rational &x) Const |
| Rational inequality operator. | |
| Bool | operator>= (Const Rational &x) Const |
| Rational >= operator. | |
| Bool | operator> (Const Rational &x) Const |
| Rational > operator. | |
| Bool | operator< (Const Rational &x) Const |
| Rational < operator. | |
| Bool | operator<= (Const Rational &x) Const |
| Rational <= operator. | |
| Rational & | operator+= (Const Real x) |
| Rational plus-equals operator. | |
| Rational & | operator+= (Rational x) |
| Rational plus-equals operator. | |
| Rational & | operator-= (Const Real x) |
| Rational minus-equals operator. | |
| Rational & | operator-= (Rational x) |
| Rational minus-equals operator. | |
| Rational & | operator *= (Const Real x) |
| Rational times-equals operator. | |
| Rational & | operator *= (Rational x) |
| Rational times-equals operator. | |
| Rational & | operator/= (Const Real x) |
| Rational divide-equals operator. | |
| Rational & | operator/= (Rational x) |
| Rational divide-equals operator. | |
| Rational | operator+ (Rational &x) |
| Rational addition operator. | |
| Rational | operator- (Rational &x) |
| Rational subtraction operator. | |
| Rational | operator * (Rational &x) |
| Rational times operator. | |
| Rational | operator/ (Rational &x) |
| Rational divide operator. | |
| Rational | operator+ (Const Real x) |
| Rational add to Real operator. | |
| Rational | operator- (Const Real x) |
| Rational subtract from Real operator. | |
| Rational | operator * (Const Real x) |
| Rational multiply by Real operator. | |
| Rational | operator/ (Const Real x) |
| Rational divide by Real operator. | |
| String | print (String s=0) Const |
| Print Rational prefixed by String. | |
Protected Attributes | |
| Integer | m_num |
| Integer | m_den |
| Static char | s_buf [128] |
Friends | |
| ostream & | operator<< (ostream &, Rational &) |
| istream & | operator>> (istream &is, Rational &p) |
| Bool | operator== (Integer &i, Rational &p) |
| Bool | operator== (Rational &p, Integer &i) |
| Bool | operator!= (Integer &i, Rational &p) |
| Bool | operator!= (Rational &p, Integer &i) |
| Bool | operator>= (Rational &p, Integer &r) |
| Bool | operator>= (Integer &i, Rational &p) |
| Bool | operator> (Rational &p, Integer &i) |
| Bool | operator> (Integer &i, Rational &p) |
| Bool | operator<= (Rational &p, Integer &i) |
| Bool | operator<= (Integer &i, Rational &p) |
| Bool | operator== (Real &r, Rational &p) |
| Bool | operator== (Rational &p, Real &r) |
| Bool | operator!= (Real &r, Rational &p) |
| Bool | operator!= (Rational &p, Real &r) |
| Bool | operator>= (Rational &p, Real &r) |
| Bool | operator>= (Real &r, Rational &p) |
| Bool | operator> (Rational &p, Real &r) |
| Bool | operator> (Real &r, Rational &p) |
| Bool | operator<= (Rational &p, Real &r) |
| Bool | operator<= (Real &r, Rational &p) |
Definition at line 28 of file Rational.h.
| Rational::Rational | ( | ) | [inline] |
Default constructor.
Definition at line 58 of file Rational.h.
Referenced by operator *(), operator+(), operator+=(), operator-(), and operator/().
| Rational::Rational | ( | Integer | i | ) | [inline] |
| Rational::Rational | ( | Const Rational & | x | ) | [inline] |
| Rational::Rational | ( | Real | x | ) | [inline] |
Construct Rational given a fractional value.
| x | Rational fraction expressed as a Real |
Definition at line 68 of file Rational.h.
References m_den, m_num, and RealToRational().
00068 : m_num(0), m_den(0) { RealToRational( x, m_num, m_den ); }
Construct Rational given a Real fractional value, determine its rational approximation, assign numerator and denominator to reference arguments.
| x | Real fractional reference value | |
| num | Reference Integer numerator of derived rational fraction approximation | |
| den | Reference Integer denominator of derived rational fraction approximation |
Definition at line 82 of file Rational.h.
References m_den, m_num, and RealToRational().
00082 : m_num(0), m_den(0) { 00083 RealToRational( x, num, den ); 00084 m_num = num; 00085 m_den = den; 00086 }
Construct Rational given a Rational, determine its rational approximation, assign numerator and denominator to reference arguments.
| x | Rational value | |
| num | Reference Integer numerator of derived rational fraction approximation | |
| den | Reference Integer denominator of derived rational fraction approximation |
Definition at line 92 of file Rational.h.
References m_den, m_num, quotient(), and RealToRational().
00092 : m_num(0), m_den(0) { 00093 RealToRational( x.quotient(), num, den ); 00094 m_num = num; 00095 m_den = den; 00096 }
Rational multiply by Real operator.
Definition at line 206 of file Rational.h.
References Rational(), and Return.
Rational times operator.
Definition at line 186 of file Rational.h.
References quotient(), Rational(), and Return.
Rational times-equals operator.
Definition at line 161 of file Rational.h.
References quotient(), and Return.
Rational times-equals operator.
Definition at line 156 of file Rational.h.
References Return.
00156 { 00157 Return( *this = quotient() * x ); 00158 }
Rational add to Real operator.
Definition at line 196 of file Rational.h.
References Rational(), and Return.
Rational addition operator.
Definition at line 176 of file Rational.h.
References quotient(), Rational(), and Return.
Rational plus-equals operator.
Definition at line 141 of file Rational.h.
References quotient(), Rational(), and Return.
Rational plus-equals operator.
Definition at line 136 of file Rational.h.
References Rational(), and Return.
Rational subtract from Real operator.
Definition at line 201 of file Rational.h.
References Rational(), and Return.
Rational subtraction operator.
Definition at line 181 of file Rational.h.
References quotient(), Rational(), and Return.
Rational minus-equals operator.
Definition at line 151 of file Rational.h.
References quotient(), and Return.
Rational minus-equals operator.
Definition at line 146 of file Rational.h.
References Return.
00146 { 00147 Return( *this = quotient() - x ); 00148 }
Rational divide by Real operator.
Definition at line 211 of file Rational.h.
References Rational(), and Return.
Rational divide operator.
Definition at line 191 of file Rational.h.
References quotient(), Rational(), and Return.
Rational divide-equals operator.
Definition at line 171 of file Rational.h.
References quotient(), and Return.
Rational divide-equals operator.
Definition at line 166 of file Rational.h.
References Return.
00166 { 00167 Return( *this = quotient() / x ); 00168 }
Rational < operator.
Definition at line 126 of file Rational.h.
References Return.
00126 { 00127 Return quotient() < x.quotient(); 00128 }
Rational <= operator.
Definition at line 131 of file Rational.h.
References Return.
00131 { 00132 Return quotient() <= x.quotient(); 00133 }
Rational > operator.
Definition at line 121 of file Rational.h.
References Return.
00121 { 00122 Return quotient() > x.quotient(); 00123 }
Rational >= operator.
Definition at line 116 of file Rational.h.
References Return.
00116 { 00117 Return quotient() >= x.quotient(); 00118 }
| ostream& operator<< | ( | ostream & | os, | |
| Rational & | r | |||
| ) | [friend] |
| istream& operator>> | ( | istream & | is, | |
| Rational & | p | |||
| ) | [friend] |
Definition at line 27 of file Rational.cpp.
00028 { 00029 char ch; 00030 is >> ch && (ch == '{' || ch == '(') 00031 && is >> p.m_num >> ch && ch == ',' 00032 && is >> p.m_den >> ch && (ch == '}' || ch == '('); 00033 Return is; 00034 }
Integer Rational::m_den [protected] |
Definition at line 231 of file Rational.h.
Referenced by operator!=(), operator=(), operator==(), operator>>(), print(), and Rational().
Integer Rational::m_num [protected] |
Definition at line 230 of file Rational.h.
Referenced by operator!=(), operator=(), operator==(), operator>>(), print(), and Rational().
Character Rational::s_buf [protected] |
1.4.7