Rational number representation. More...
Public Member Functions | |
| Rational () | |
| Constructs default instance. | |
| Rational (long long numerator, unsigned int denominator) | |
| Create initialized instance. | |
| Rational (const Rational &other, unsigned int newDenominator) | |
| Converts some Rational value to another denominator. | |
| bool | noValue () const |
| Indicates if Rational has no value. | |
| template<typename T > | |
| T | convertTo () const |
| Converts Rational representation to needed number type. More... | |
| operator float () const | |
| Implicit conversion to float number type. | |
| operator double () const | |
| Implicit conversion to double number type. | |
| std::string | toString () const |
| string representation of Rational | |
| bool | operator== (const Rational &right) const |
| Rational comparison. | |
| 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 |
Public Attributes | |
| long long | numerator |
| Numerator. | |
| unsigned int | denominator |
| Denominator. | |
Static Public Attributes | |
| static const long long | NO_VALUE |
| This value indicates that value is in not set. | |
Rational number representation.
|
inline |
Converts Rational representation to needed number type.
Target number type should have accessible constructor from int type, and should have visible operator/.