An object of the class Gmpq is an arbitrary precision rational number based on the Gnu Multiple Precision Arithmetic Library.
#include <CGAL/Gmpq.h>
 
the field type, which is Gmpz.

 
creates an uninitialized multiple precision rational number q.
 
 
creates a multipleprecision rational number initialized with
i.
 
 
creates a multipleprecision rational number initialized with
n.
 
 
creates a multipleprecision rational number initialized with
n/d.
 
 
creates a multipleprecision rational number initialized with
n/d.
 
 
creates a multipleprecision rational number initialized with
n/d.
 
 
creates a multipleprecision rational number initialized with
n/d.
 
 
creates a multipleprecision rational number initialized with
d.
 
 
creates a multipleprecision rational number initialized with
str.
 
 
creates a multipleprecision rational number initialized with
str.


 writes q to the ostream out, in the form n/d. 

 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 floatingpoint 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.

 returns the numerator of q. 

 returns the denominator of q. 