Calculator
Step 6
|
#include <istream>
#include <limits>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include "gcd.hpp"
#include "ioflags.hpp"
#include "power10.hpp"
Go to the source code of this file.
Classes | |
class | zero_denominator |
Exception class if the denominator is ever zero. More... | |
class | rational< T > |
Represent a rational number (fraction) as a numerator and denominator. More... | |
Functions | |
template<class T > | |
rational< T > | operator- (rational< T > const &r) |
Negate a rational number. More... | |
template<class T > | |
rational< T > | absval (rational< T > const &r) |
template<class T > | |
rational< T > | operator+ (rational< T > lhs, rational< T > const &rhs) |
Addition. More... | |
template<class T > | |
rational< T > | operator+ (rational< T > lhs, T const &rhs) |
Addition. More... | |
template<class T > | |
rational< T > | operator+ (T const &lhs, rational< T > rhs) |
Addition. More... | |
template<class T > | |
rational< T > | operator- (rational< T > lhs, rational< T > const &rhs) |
Subtraction. More... | |
template<class T > | |
rational< T > | operator- (rational< T > lhs, T const &rhs) |
Subtraction. More... | |
template<class T > | |
rational< T > | operator- (T const &lhs, rational< T > rhs) |
Subtraction. More... | |
template<class T > | |
rational< T > | operator* (rational< T > lhs, rational< T > const &rhs) |
Multiplication. More... | |
template<class T > | |
rational< T > | operator* (rational< T > lhs, T const &rhs) |
Multiplication. More... | |
template<class T > | |
rational< T > | operator* (T const &lhs, rational< T > rhs) |
Multiplication. More... | |
template<class T > | |
rational< T > | operator/ (rational< T > lhs, rational< T > const &rhs) |
Division. More... | |
template<class T > | |
rational< T > | operator/ (rational< T > lhs, T const &rhs) |
Division. More... | |
template<class T > | |
rational< T > | operator/ (T const &lhs, rational< T > rhs) |
Division. More... | |
template<class T , class U > | |
bool | operator== (rational< T > const &a, rational< U > const &b) |
Equality comparison. More... | |
template<class T > | |
bool | operator== (rational< T > const &lhs, T rhs) |
Equality comparison. More... | |
template<class T > | |
bool | operator== (T lhs, rational< T > const &rhs) |
Equality comparison. More... | |
template<class T > | |
bool | operator< (rational< T > const &a, rational< T > const &b) |
Less-than comparison. More... | |
template<class T > | |
bool | operator< (rational< T > const &a, T const &b) |
Less-than comparison. More... | |
template<class T > | |
bool | operator< (T const &a, rational< T > const &b) |
Less-than comparison. More... | |
template<class T , class U > | |
bool | operator!= (rational< T > const &a, rational< U > const &b) |
Inequality comparison. More... | |
template<class T > | |
bool | operator!= (rational< T > const &a, T b) |
Inequality comparison. More... | |
template<class T > | |
bool | operator!= (T a, rational< T > const &b) |
Inequality comparison. More... | |
template<class T > | |
bool | operator<= (rational< T > const &a, rational< T > const &b) |
Less-than-or-equal comparison. More... | |
template<class T > | |
bool | operator<= (rational< T > const &a, T const &b) |
Less-than-or-equal comparison. More... | |
template<class T > | |
bool | operator<= (T const &a, rational< T > const &b) |
Less-than-or-equal comparison. More... | |
template<class T > | |
bool | operator> (rational< T > const &a, rational< T > const &b) |
Greater-than comparison. More... | |
template<class T > | |
bool | operator> (rational< T > const &a, T const &b) |
Greater-than comparison. More... | |
template<class T > | |
bool | operator> (T const &a, rational< T > const &b) |
Greater-than comparison. More... | |
template<class T > | |
bool | operator>= (rational< T > const &a, rational< T > const &b) |
Greater-than-or-equal comparison. More... | |
template<class T > | |
bool | operator>= (rational< T > const &a, T const &b) |
Greater-than-or-equal comparison. More... | |
template<class T > | |
bool | operator>= (T const &a, rational< T > const &b) |
Greater-than-or-equal comparison. More... | |
template<class T , class Char , class Traits > | |
std::basic_istream< Char, Traits > & | operator>> (std::basic_istream< Char, Traits > &in, rational< T > &rat) |
Input operator. More... | |
template<class T , class Char , class Traits > | |
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &out, rational< T > const &rat) |
Output operator. More... | |
Definition at line 292 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
|
inline |
Inequality comparison.
Definition at line 442 of file rational.hpp.
|
inline |
Inequality comparison.
Definition at line 449 of file rational.hpp.
|
inline |
Inequality comparison.
Definition at line 456 of file rational.hpp.
Multiplication.
Definition at line 349 of file rational.hpp.
Multiplication.
Definition at line 357 of file rational.hpp.
Multiplication.
Definition at line 365 of file rational.hpp.
Negate a rational number.
Definition at line 286 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
Subtraction.
Definition at line 324 of file rational.hpp.
Subtraction.
Definition at line 332 of file rational.hpp.
Subtraction.
Definition at line 340 of file rational.hpp.
Division.
Definition at line 389 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
Less-than comparison.
Definition at line 421 of file rational.hpp.
References rational< T >::numerator().
bool operator< | ( | rational< T > const & | a, |
T const & | b | ||
) |
Less-than comparison.
Definition at line 428 of file rational.hpp.
bool operator< | ( | T const & | a, |
rational< T > const & | b | ||
) |
Less-than comparison.
Definition at line 435 of file rational.hpp.
std::basic_ostream<Char, Traits>& operator<< | ( | std::basic_ostream< Char, Traits > & | out, |
rational< T > const & | rat | ||
) |
Output operator.
Definition at line 562 of file rational.hpp.
References rational< T >::numerator().
Less-than-or-equal comparison.
Definition at line 463 of file rational.hpp.
|
inline |
Less-than-or-equal comparison.
Definition at line 470 of file rational.hpp.
|
inline |
Less-than-or-equal comparison.
Definition at line 477 of file rational.hpp.
Equality comparison.
Definition at line 397 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
bool operator== | ( | rational< T > const & | lhs, |
T | rhs | ||
) |
Equality comparison.
Definition at line 405 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
bool operator== | ( | T | lhs, |
rational< T > const & | rhs | ||
) |
Equality comparison.
Definition at line 413 of file rational.hpp.
References rational< T >::denominator(), and rational< T >::numerator().
|
inline |
|
inline |
Greater-than-or-equal comparison.
Definition at line 505 of file rational.hpp.
|
inline |
Greater-than-or-equal comparison.
Definition at line 512 of file rational.hpp.
|
inline |
Greater-than-or-equal comparison.
Definition at line 519 of file rational.hpp.
std::basic_istream<Char, Traits>& operator>> | ( | std::basic_istream< Char, Traits > & | in, |
rational< T > & | rat | ||
) |
Input operator.
Definition at line 526 of file rational.hpp.