Fraction

Functions

template<class T>
inline Fraction<T> abs(const Fraction<T> f)
template<class T>
inline Fraction<T> operator+(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline Fraction<T> operator-(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline Fraction<T> operator*(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline Fraction<T> operator/(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline Fraction<T> operator-(const Fraction<T> &f)
template<class T>
inline bool operator==(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline bool operator!=(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline bool operator<(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline bool operator<=(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline bool operator>(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline bool operator>=(const Fraction<T> &a, const Fraction<T> &b)
template<class T>
inline std::ostream &operator<<(std::ostream &os, const Fraction<T> &fraction)
template<class T>
class Fraction

Public Functions

inline Fraction(const T num = Constants<T>::zero(), const T den = Constants<T>::one())
inline T num() const

Numerator.

inline T den() const

Denominator.

inline double approx() const

Numerical approximation.

inline Fraction inverse() const
inline void operator+=(const Fraction other)
inline void operator-=(const Fraction other)
inline void operator*=(const Fraction other)
inline void operator/=(const Fraction other)

Private Functions

inline T GCD(const T a, const T b)
inline void simplify()

Private Members

T m_num
T m_den
template<class T>
class Constants<Fraction<T>>

Public Static Functions

static inline Fraction<T> zero()
static inline Fraction<T> one()
static inline Fraction<T> infinity()