Class

CGAL::Gmpz

Definition

An object of the class Gmpz is an arbitrary precision integer based on the Gnu Multiple Precision Arithmetic Library.

#include <CGAL/Gmpz.h>

Is Model for the Concepts

EuclideanRing
RealEmbeddable

Creation

Gmpz z;
creates an uninitialized multiple precision integer z.

Gmpz z ( int i);
creates a multiple-precision integer initialized with i.

Gmpz z ( double d);
creates a multiple-precision integer initialized with the integral part of d.

Operations

Gmpz & ++ z prefix increment.
Gmpz z ++ postfix increment.
Gmpz & -- z prefix decrement.
Gmpz z -- postfix decrement.

Gmpz a >> unsigned long i rightshift by i.
Gmpz a << unsigned long i leftshift by i.
Gmpz & z >>= long i rightshift by i, where i>=0.
Gmpz & z <<= long i leftshift by i, where i>=0.

Gmpz a & b bitwise AND.
Gmpz a | b bitwise IOR.
Gmpz a ^ b bitwise XOR.
Gmpz & z &= b bitwise AND.
Gmpz & z |= b bitwise IOR.
Gmpz & z ^= b bitwise XOR.

Sign z.sign () const Returns the sign of z.

size_t z.bit_size () const Returns the bit-size (that is, the number of bits needed to represent the mantissa) of z.

size_t z.size () const Returns the size in limbs of z. A limb is the type used by Gmp to represent the integer (usually long).

size_t z.approximate_decimal_length () const
Returns the approximate number of decimal digits needed to represent z. Approximate means either a correct result, either the correct result plus one.

double z.to_double () const Returns a double approximation of z. The integer is truncated if needed. If the exponent of the conversion is too big, the result is system dependent (returning infinity where it is supported).

std::ostream& std::ostream& out << z writes z to the ostream out.
std::istream& std::istream& in >> & z reads an integer from in, then converts it to a Gmpz.

Implementation

Gmpzs are reference counted.