#include <rational.hpp>
Public Types | |
| typedef T | value_type |
| Convenience typedef for the integral type of the numerator and denominator. | |
Public Member Functions | |
| rational (value_type num=0) | |
| rational (value_type num, value_type den) | |
| rational (double r) | |
| template<class U> | |
| rational (rational< U > const &that) | |
| Copy from a different type of rational. | |
| value_type | numerator () const |
| Return the numerator. | |
| value_type | denominator () const |
| Return the denominator. | |
| template<class U> | |
| U | as () const |
| Convert the rational number to another type, especially floating-point. | |
| rational & | operator= (value_type) |
| Assignment of an integer. | |
| template<class U> | |
| rational & | operator= (rational< U > const &rhs) |
| Assignment of a rational with a different size. | |
| rational & | operator+= (rational const &rhs) |
| Addition assignment operator. | |
| rational & | operator+= (value_type const &rhs) |
| Addition assignment operator. | |
| rational & | operator-= (rational const &rhs) |
| Subtraction assignment operator. | |
| rational & | operator-= (value_type const &rhs) |
| Subtraction assignment operator. | |
| rational & | operator *= (rational const &rhs) |
| Multiplication assignment operator. | |
| rational & | operator *= (value_type const &rhs) |
| Multiplication assignment operator. | |
| rational & | operator/= (rational const &rhs) |
| Division assignment operator. | |
| rational & | operator/= (value_type const &rhs) |
| Division assignment operator. | |
| rational & | operator++ () |
| Pre-increment. | |
| rational & | operator-- () |
| Pre-decrement. | |
| rational | operator++ (int) |
| Post-increment. | |
| rational | operator-- (int) |
| Post-decrement. | |
Classes | |
| class | zero_denominator |
| Exception class if the denominator is ever zero. More... | |
Definition at line 16 of file rational.hpp.
| rational< T >::rational | ( | value_type | num = 0 |
) | [inline] |
Default constructor and constructor from a single value. As a default constructor, initializes to zero. Otherwise, initializes to the integer num.
| num | The integer value to use as the initial value |
Definition at line 33 of file rational.hpp.
| rational< T >::rational | ( | value_type | num, | |
| value_type | den | |||
| ) | [inline] |
Construct a rational number
| num | numerator | |
| den | denominator |
| zero_denominator | if den == 0 |
Definition at line 106 of file rational.hpp.
Initialize the rational number with an approximation of r
| r | the initial value |
Definition at line 114 of file rational.hpp.
1.5.3