xoreos
0.0.5
|
A simple rational class that holds fractions. More...
#include <rational.h>
Public Member Functions | |
Rational () | |
Rational (int num) | |
Rational (int num, int denom) | |
Rational & | operator= (const Rational &right) |
Rational & | operator= (int right) |
Rational & | operator+= (const Rational &right) |
Rational & | operator-= (const Rational &right) |
Rational & | operator*= (const Rational &right) |
Rational & | operator/= (const Rational &right) |
Rational & | operator+= (int right) |
Rational & | operator-= (int right) |
Rational & | operator*= (int right) |
Rational & | operator/= (int right) |
const Rational | operator- () const |
const Rational | operator+ (const Rational &right) const |
const Rational | operator- (const Rational &right) const |
const Rational | operator* (const Rational &right) const |
const Rational | operator/ (const Rational &right) const |
const Rational | operator+ (int right) const |
const Rational | operator- (int right) const |
const Rational | operator* (int right) const |
const Rational | operator/ (int right) const |
bool | operator== (const Rational &right) const |
bool | operator!= (const Rational &right) const |
bool | operator> (const Rational &right) const |
bool | operator< (const Rational &right) const |
bool | operator>= (const Rational &right) const |
bool | operator<= (const Rational &right) const |
bool | operator== (int right) const |
bool | operator!= (int right) const |
bool | operator> (int right) const |
bool | operator< (int right) const |
bool | operator>= (int right) const |
bool | operator<= (int right) const |
void | invert () |
Rational | getInverse () const |
int | toInt () const |
double | toDouble () const |
int | getNumerator () const |
int | getDenominator () const |
Private Member Functions | |
void | cancel () |
Private Attributes | |
int | _num |
int | _denom |
A simple rational class that holds fractions.
Definition at line 56 of file rational.h.
Common::Rational::Rational | ( | ) |
Definition at line 56 of file rational.cpp.
Referenced by operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator<(), operator<=(), operator>(), and operator>=().
Common::Rational::Rational | ( | int | num | ) |
Definition at line 61 of file rational.cpp.
Common::Rational::Rational | ( | int | num, |
int | denom | ||
) |
Definition at line 66 of file rational.cpp.
References _denom, _num, and cancel().
|
private |
Definition at line 81 of file rational.cpp.
References _denom, _num, and Common::gcd().
Referenced by operator+=(), operator-=(), and Rational().
|
inline |
Definition at line 108 of file rational.h.
References _denom.
Referenced by Common::Timestamp::Timestamp().
Rational Common::Rational::getInverse | ( | ) | const |
Definition at line 279 of file rational.cpp.
References inverse().
Referenced by operator/=(), and Common::Timestamp::Timestamp().
|
inline |
Definition at line 107 of file rational.h.
References _num.
Referenced by Common::Timestamp::Timestamp().
void Common::Rational::invert | ( | ) |
Definition at line 267 of file rational.cpp.
bool Common::Rational::operator!= | ( | const Rational & | right | ) | const |
Definition at line 223 of file rational.cpp.
bool Common::Rational::operator!= | ( | int | right | ) | const |
Definition at line 247 of file rational.cpp.
Definition at line 183 of file rational.cpp.
const Rational Common::Rational::operator* | ( | int | right | ) | const |
Definition at line 207 of file rational.cpp.
Definition at line 135 of file rational.cpp.
References _denom, _num, and Common::gcd().
Rational & Common::Rational::operator*= | ( | int | right | ) |
Definition at line 159 of file rational.cpp.
References Rational().
Definition at line 171 of file rational.cpp.
const Rational Common::Rational::operator+ | ( | int | right | ) | const |
Definition at line 195 of file rational.cpp.
Definition at line 105 of file rational.cpp.
References _denom, _num, cancel(), and Common::gcd().
Rational & Common::Rational::operator+= | ( | int | right | ) |
Definition at line 151 of file rational.cpp.
References Rational().
const Rational Common::Rational::operator- | ( | ) | const |
Definition at line 167 of file rational.cpp.
References _denom, _num, and Rational().
Definition at line 177 of file rational.cpp.
const Rational Common::Rational::operator- | ( | int | right | ) | const |
Definition at line 201 of file rational.cpp.
Definition at line 120 of file rational.cpp.
References _denom, _num, cancel(), and Common::gcd().
Rational & Common::Rational::operator-= | ( | int | right | ) |
Definition at line 155 of file rational.cpp.
References Rational().
Definition at line 189 of file rational.cpp.
const Rational Common::Rational::operator/ | ( | int | right | ) | const |
Definition at line 213 of file rational.cpp.
Definition at line 147 of file rational.cpp.
References getInverse().
Rational & Common::Rational::operator/= | ( | int | right | ) |
Definition at line 163 of file rational.cpp.
References Rational().
bool Common::Rational::operator< | ( | const Rational & | right | ) | const |
Definition at line 231 of file rational.cpp.
bool Common::Rational::operator< | ( | int | right | ) | const |
Definition at line 255 of file rational.cpp.
References Rational().
bool Common::Rational::operator<= | ( | const Rational & | right | ) | const |
Definition at line 239 of file rational.cpp.
bool Common::Rational::operator<= | ( | int | right | ) | const |
Definition at line 263 of file rational.cpp.
References Rational().
Definition at line 91 of file rational.cpp.
Rational & Common::Rational::operator= | ( | int | right | ) |
Definition at line 98 of file rational.cpp.
bool Common::Rational::operator== | ( | const Rational & | right | ) | const |
Definition at line 219 of file rational.cpp.
bool Common::Rational::operator== | ( | int | right | ) | const |
Definition at line 243 of file rational.cpp.
bool Common::Rational::operator> | ( | const Rational & | right | ) | const |
Definition at line 227 of file rational.cpp.
bool Common::Rational::operator> | ( | int | right | ) | const |
Definition at line 251 of file rational.cpp.
References Rational().
bool Common::Rational::operator>= | ( | const Rational & | right | ) | const |
Definition at line 235 of file rational.cpp.
bool Common::Rational::operator>= | ( | int | right | ) | const |
Definition at line 259 of file rational.cpp.
References Rational().
double Common::Rational::toDouble | ( | ) | const |
Definition at line 291 of file rational.cpp.
int Common::Rational::toInt | ( | ) | const |
Definition at line 287 of file rational.cpp.
|
private |
Definition at line 112 of file rational.h.
Referenced by cancel(), getDenominator(), invert(), operator!=(), operator*=(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), Rational(), toDouble(), and toInt().
|
private |
Definition at line 111 of file rational.h.
Referenced by cancel(), getNumerator(), invert(), operator!=(), operator*=(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), Rational(), toDouble(), and toInt().