## CGAL::Fixed_precision_nt

### Definition

The class Fixed_precision_nt provides 24-bit numbers in fixed point representation. Basically these numbers are integers in the range [-224,224] with a multiplying factor 2b. The multiplying factor 2b has to be initialized by the user before the construction of the first Fixed_precision_nt and is common to all variables.

The interest of such a number type is that geometric predicates can be overloaded to get exact and very efficient predicates. The drawback is that any Fixed_precision_nt is rounded to the nearest multiple of 2b, which yields to a very poor arithmetic. The idea is to not use the arithmetic on Fixed_precision_nt but only the specialized predicates.

Note: you must call CGAL::force_ieee_double_precision() in order for the Fixed_precision_nt to work properly on Intel platforms. This initializes the FPU to an IEEE compliant rounding mode which is not the default.

#include <CGAL/Fixed_precision_nt.h>

### Is Model for the Concept

RingNumberType

### Creation

Fixed_precision_nt fvar;
| Declaration.
Fixed_precision_nt fvar ( double d);
| Initialization of a variable. The variable is rounded to the nearest legal fixed number (i.e. a multiple of 2b= Fixed_precision_nt::unit_value()
Fixed_precision_nt fvar ( fval);
| Declaration and initialization.
Fixed_precision_nt fvar ( int i);
| Declaration and initialization with an integer.

### Operations

Fixed_precision_nt &
| fvar = fval | Assignment.
bool | is_valid ( fval) | In case of overflow or division by 0, numbers becomes invalid. If the precision is changed by usage of Fixed_precision_nt::init(), already existing numbers may become invalid if they are no longer multiple of 2b.
bool | is_finite ( fval) | Fixed_precision_nt do not implement infinite numbers. is_finite is identical to is_valid.

The comparison operations ==, !=, <, >, <=, and >= are all available.

The arithmetic operators +, -, *, /, +=, -=, *= and /= are all available. The result of the computation is rounded to the nearest legal Fixed_precision_nt. Overflow is possible, and even probable in case of multiplication or division. Fixed_precision_nt are designed to use specialized predicates, not to use arithmetic.

double | to_double ( fval) | casts to double.

### Precision initialization

As mentioned before, the Fixed_precision_nt numbers takes their values in an interval [-224+b,224+b] of multiples of 2b, this number b as to be defined before any use of Fixed_precision_nt.

static bool | init ( float B) | B is an upper bound on the data, b is the smallest integer such that |B| 2b. The result of the function is false if initialization was already done, in that case already existing Fixed_precision_nt may become invalid.
static float | unit_value () | returns 2b.
static float | upper_bound () | returns 224+b.

### Perturbation scheme

Fixed_precision_nt implements perturbation scheme as described by Alliez, Devillers and Snoeyink [ADS98]. The perturbation mode can be activated or deactivated for different kinds of perturbations. The default mode is no perturbation.

static void | perturb_incircle ()
|  | Activate. side_of_oriented_circle predicate of 4 cocircular points answers degenerate only if the 4 points are colinear.
static void | unperturb_incircle ()
|  | Deactivate
static bool | is_perturbed_incircle ()
|  | returns current mode
static void | perturb_insphere ()
|  | Activate. side_of_oriented_sphere predicate of 5 cospherical points answers degenerate only if the 5 points are coplanar.
static void | unperturb_insphere ()
|  | Deactivate
static bool | is_perturbed_insphere ()
|  | returns current mode

### Geometric predicates

Through overloading mechanisms, functions such that orientation for Point_2<Cartesian< Fixed_precision_nt> > will correctly call the function below.

Orientation | orientationC2 ( x0, y0, x1, y1, x2, y2)

Oriented_side

side_of_oriented_circleC2 ( | x0, y0, x1, y1, x2, y2, x3, y3)

|  | Perturbation mode can be activated.

Orientation

orientationC3 ( | x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3)

Oriented_side

side_of_oriented_sphereC3 ( | x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)

|  | Perturbation mode can be activated.