CGAL 5.5.2 - Number Types
CGAL::Mpzf Struct Reference

#include <CGAL/Mpzf.h>

Definition

An object of the class Mpzf is a multiple-precision floating-point number which can represent numbers of the form \( m*2^e\), where \( m\) is an arbitrary precision integer based on the GMP library, and \( e\) is of type int.

This type can be considered exact, even if the exponent is not a multiple-precision number. A Mpzf constructed from an integer or a normalized finite floating point number represents exactly that number. This number type offers functionality very similar to MP_Float and Gmpzf but is faster.

Is Model Of:

IntegralDomainWithoutDivision

RealEmbeddable

Implementation

This class is only available on platforms on which GMP uses 64 bit limbs and the endianness is either big-endian or little-endian. The macro CGAL_HAS_MPZF will be defined when including CGAL/Mpzf.h if this is true. This class makes the assumption that the representation of a double in memory follows IEEE 754.

Currently, an Mpzf contains an array of a few limbs, in which it stores the data as long as it fits. If it does not fit, it dynamically allocates memory with new, and de-allocates it when it is done. Code to recycle the allocated memory (per thread) is included but disabled at the moment.

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out, const Mpzf &f)
 writes a double approximation of f to the ostream out.
 
std::istream & operator>> (std::istream &in, Mpzf &f)
 reads a double from in, then converts it to a Mpzf.
 

Creation

 Mpzf ()
 creates a Mpzf initialized with 0.
 
 Mpzf (int i)
 creates a Mpzf initialized with i.
 
 Mpzf (long int l)
 creates a Mpzf initialized with l.
 
 Mpzf (const Gmpz &i)
 creates a Mpzf initialized with i.
 
 Mpzf (const mpz_class &i)
 creates a Mpzf initialized with i.
 
 Mpzf (double d)
 creates a Mpzf initialized with d.
 

Conversion

 operator Gmpq () const
 creates a Gmpq initialized with *this.
 
 operator mpq_class () const
 creates a mpq_class initialized with *this.