RingNumberType

Definition

The concept RingNumberType defines the syntactic requirements a number type must meet in order to be used in CGAL as a ring type. This implies that CGAL::Number_type_traits<RingNumberType>::Has_division is not required to be CGAL::Tag_true. Unsigned numbers are excluded due to semantical limitations in the ordering.

Refines

CopyConstructible, Assignable

Creation

RingNumberType n1;
Declaration of a variable.


RingNumberType n1 ( int i);
Declaration and initialization with a small integer constant i, 0 i 127. The neutral elements for addition (zero) and multiplication (one) are needed quite often, but sometimes other small constants are useful too. The value 127 was chosen such that even signed 8 bit number types can fulfill this condition.

Operations

The comparison operators need to be provided.

bool n1 == n2
bool n1 != n2
bool n1 < n2
bool n1 > n2
bool n1 <= n2
bool n1 >= n2

In addition, the comparisons with small values of type int are also required.

bool int n1 == n2
bool int n1 != n2
bool int n1 < n2
bool int n1 > n2
bool int n1 <= n2
bool int n1 >= n2
bool n1 == int n2
bool n1 != int n2
bool n1 < int n2
bool n1 > int n2
bool n1 <= int n2
bool n1 >= int n2

The arithmetic operators for the addition, subtraction and multiplication are required as well.

RingNumberType n1 + n2
RingNumberType n1 - n2
RingNumberType n1 * n2
RingNumberType - n
RingNumberType n1 += n2
RingNumberType n1 -= n2
RingNumberType n1 *= n2

And similarly, the mixed operators with small values of type int are also required.

RingNumberType int n1 + n2
RingNumberType int n1 - n2
RingNumberType int n1 * n2
RingNumberType n1 + int n2
RingNumberType n1 - int n2
RingNumberType n1 * int n2
RingNumberType n1 += int n2
RingNumberType n1 -= int n2
RingNumberType n1 *= int n2

The following accessory functions are needed for special purposes :

bool is_valid ( n) Not all values of a number type need be valid. The function is_valid checks this. For example, an expression like NT(0)/NT(0) can result in an invalid number. Routines may have as a precondition that all numerical values are valid.

bool is_finite ( n) When two large values are multiplied, the result may not fit in a NT. Some number types (e.g. the standard float and double types) have a way to represent a too big value as infinity. is_finite implies is_valid.

double to_double ( n) gives the double value for a number type. This is usually an approximation for the real (stored) value. It can be used to send numbers to a renderer or to store them in a file.

std::pair<double,double>
to_interval ( n) gives a double interval that encloses n.

Has Models

C++ built-in number types
CGAL::Filtered_exact<RingNumberType, ET>
CGAL::Fixed_precision_nt
CGAL::Gmpq
CGAL::Gmpz
CGAL::Interval_nt
CGAL::Interval_nt_advanced
CGAL::Lazy_exact_nt<RingNumberType>
CGAL::MP_Float
CGAL::Quotient<RingNumberType>
leda_integer
leda_rational
leda_bigfloat
leda_real

See Also

EuclideanRingNumberType
FieldNumberType
CGAL::Ring_tag
Support Library Manual