An object of the class Gmpq is an arbitrary precision rational number based on the Gnu Multiple Precision Arithmetic Library.
#include <CGAL/Gmpq.h>
Gmpq q; | |
creates an uninitialized Gmpq q.
| |
Gmpq q ( int i); | |
creates a Gmpq initialized with
i.
| |
Gmpq q ( Gmpz n); | |
creates a Gmpq initialized with
n.
| |
Gmpq q ( Gmpfr f); | |
creates a Gmpq initialized with
f.
| |
Gmpq q ( int n, int d); | |
creates a Gmpq initialized with
n/d.
| |
Gmpq q ( signed long n, unsigned long d); | |
creates a Gmpq initialized with
n/d.
| |
Gmpq q ( unsigned long n, unsigned long d); | |
creates a Gmpq initialized with
n/d.
| |
Gmpq q ( Gmpz n, Gmpz d); | |
creates a Gmpq initialized with
n/d.
| |
Gmpq q ( double d); | |
creates a Gmpq initialized with
d.
| |
Gmpq q ( std::string str); | |
creates a Gmpq initialized with str, which can
be an integer like "41" or a fraction like "41/152". White
space is allowed in the string, and ignored.
| |
Gmpq q ( std::string str, int base); | |
creates a Gmpq initialized with str in base
base, which is an integer between 2 and 62. White space
in the string is ignored.
|
std::ostream& | std::ostream& out << q | writes q to the ostream out, in the form n/d. |
std::istream& | std::istream& in >> & q | reads a number from in, then converts it to a Gmpq. The number may be an integer, a rational number in the form n/d, or a floating-point number. |
There are two access functions, namely to the numerator and the denominator of a rational. Note that these values are not uniquely defined. It is guaranteed that q.numerator() and q.denominator() return values nt_num and nt_den such that q = nt_num/nt_den, only if q.numerator() and q.denominator() are called consecutively wrt. q, i.e. q is not involved in any other operation between these calls.
Gmpz | q.numerator () const | returns the numerator of q. |
Gmpz | q.denominator () const | returns the denominator of q. |