Public Member Functions | |
| Rational () | |
| Initializes to 0. | |
| Rational (long num) | |
| Create a Rational from a long. | |
| Rational (int num) | |
| Create a Rational from an int. | |
| Rational (const AccurateFloat &) | |
| Create a Rational from an AccurateFloat. | |
| Rational (const Integer &num, const Integer &den) | |
| Create a Rational as the quotient of two Integers. | |
| Rational (long num, long den) | |
| Create a Rational as the quotient of two longs. | |
| Rational (const Integer &num, long den) | |
| Create a Rational as the quotient of an Integer num and a long . | |
| Rational (long num, const Integer &den) | |
| Create a Rational as the quotient of a long num and an Integer . | |
| Rational (double b) | |
| Create a Rational from a double. | |
| Rational & | set (const char *s) |
| Rational & | set (mpq_srcptr src) |
| for the seldom case of unwrapped GMP objects coexisting with us | |
| std::string | to_string (int base=10) const |
| Convert rational to string. | |
| void | swap (Rational &b) |
| Swaps the values. | |
| bool | operator! () const |
| Comparison with 0. | |
| operator bool () const | |
| Comparison with 0. | |
| Rational & | negate () |
| In-place negation. | |
| Rational & | operator+= (const Rational &b) |
| Addition operator. | |
| Rational & | operator+= (const Integer &b) |
| Addition operator. | |
| Rational & | operator+= (long b) |
| Addition operator. | |
| Rational & | operator-= (const Rational &b) |
| Subtraction operator. | |
| Rational & | operator-= (const Integer &b) |
| Subtraction operator. | |
| Rational & | operator-= (long b) |
| Subtraction operator. | |
| Rational & | operator*= (const Rational &b) |
| Multiplication operator. | |
| Rational & | operator*= (const Integer &b) |
| Multiplication operator. | |
| Rational & | operator*= (long b) |
| Multiplication operator. | |
| Rational & | operator/= (const Rational &b) |
| Division operator. | |
| Rational & | operator/= (const Integer &b) |
| Division operator. | |
| Rational & | operator/= (long b) |
| Division operator. | |
| Rational & | operator<<= (unsigned long k) |
| Multiply with 2**k. | |
| Rational & | operator>>= (unsigned long k) |
| Divide thru 2**k. | |
| int | compare (const Rational &b) const |
| Comparison. | |
| int | compare (long b) const |
| Comparison. | |
| int | compare (int b) const |
| Comparison. | |
| int | compare (const Integer &b) const |
| Comparison. | |
| int | compare (double b) const |
| Comparison. | |
Protected Attributes | |
| mpq_t | rep |
| GMP's representation. | |
Friends | |
| void | relocate (Rational *from, Rational *to) |
| Rational | operator+ (const Rational &a, const Rational &b) |
| Addition of two Rationals. | |
| Rational | operator+ (const Rational &a, const Integer &b) |
| Addition. | |
| Rational | operator+ (const Rational &a, long b) |
| Addition. | |
| Rational | operator- (const Rational &a, const Rational &b) |
| Subtraction. | |
| Rational | operator- (const Rational &a, const Integer &b) |
| Subtraction. | |
| Rational | operator- (const Integer &a, const Rational &b) |
| Subtraction. | |
| Rational | operator- (const Rational &a, long b) |
| Subtraction. | |
| Rational | operator- (long a, const Rational &b) |
| Subtraction. | |
| Rational | operator- (const Rational &a) |
| Subtraction. | |
| Rational | operator* (const Rational &a, const Rational &b) |
| Multiplication. | |
| Rational | operator* (const Rational &a, const Integer &b) |
| Multiplication. | |
| Rational | operator* (const Rational &a, long b) |
| Multiplication. | |
| Rational | operator/ (const Rational &a, const Rational &b) |
| Division. | |
| Rational | operator/ (const Rational &a, long b) |
| Division. | |
| Rational | operator/ (long a, const Rational &b) |
| Division. | |
| Rational | operator/ (const Rational &a, const Integer &b) |
| Division. | |
| Rational | operator/ (const Integer &a, const Rational &b) |
| Division. | |
| Rational | floor (const Rational &a) |
| The floor function. | |
| Rational | ceil (const Rational &a) |
| The ceiling function. | |
| Rational | operator<< (const Rational &a, unsigned long k) |
| Multiply with 2**k. | |
| Rational | operator>> (const Rational &a, unsigned long k) |
| Divide by 2**k. | |
| Rational& pm::Rational::set | ( | const char * | s | ) | [inline] |
Conversion from a printable representation. Numerator and denominator are expected delimited by `/'. Omitted denominator assumed equal to 1.
Accelerated combination of copy constructor and destructor. Aimed to be used in container classes only!