CGAL 5.5.1  Number Types

#include <CGAL/Gmpq.h>
An object of the class Gmpq
is an arbitrary precision rational number based on the GMP library.
Implementation
Gmpq
s are reference counted.
Related Functions  
(Note that these are not member functions.)  
std::ostream &  operator<< (std::ostream &out, const Gmpq &q) 
writes q to the ostream out , in the form n/d .  
std::istream &  operator>> (std::istream &in, Gmpq &q) 
reads a number from in , then converts it to a Gmpq . More...  
Creation  
Gmpq ()  
creates an uninitialized Gmpq q .  
Gmpq (int i)  
creates a Gmpq initialized with i .  
Gmpq (Gmpz n)  
creates a Gmpq initialized with n .  
Gmpq (Gmpfr f)  
creates a Gmpq initialized with f .  
Gmpq (int n, int d)  
creates a Gmpq initialized with n/d .  
Gmpq (signed long n, unsigned long d)  
creates a Gmpq initialized with n/d .  
Gmpq (unsigned long n, unsigned long d)  
creates a Gmpq initialized with n/d .  
Gmpq (Gmpz n, Gmpz d)  
creates a Gmpq initialized with n/d .  
Gmpq (double d)  
creates a Gmpq initialized with d .  
Gmpq (const std::string &str)  
creates a Gmpq initialized with str , which can be an integer like "41" or a fraction like "41/152". More...  
Gmpq (const std::string &str, int base)  
creates a Gmpq initialized with str in base base , which is an integer between 2 and 62. More...  
Operations  
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  
Gmpz  numerator () const 
returns the numerator of q .  
Gmpz  denominator () const 
returns the denominator of q .  
CGAL::Gmpq::Gmpq  (  const 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.
CGAL::Gmpq::Gmpq  (  const 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.