CGAL 6.0.1  Number Types

#include <CGAL/FPU.h>
The class Set_ieee_double_precision
provides a mechanism to set the correct 53 bits precision for a block of code.
It does so by having a default constructor that sets a particular mode on the FPU which corrects the problem, and have its destructor reset the mode to its previous state.
The IEEE754 standard specifies that the precision of double precision floatingpoint numbers should be 53 bits, with 11 bits for the exponent range.
Some processors violate this rule by providing excess precision during some computations (when values are in registers). This is the case of the x86 Intel processor and compatible processors (note that the SSE2 more recent alternative FPU is fortunately not affected by this issue). The effect of such excess precision can be a problem for some computations, since it can produce socalled double rounding effects, where actually less precision is actually provided! It can also be the root of nondeterministic computations depending on compiler optimizations or not (since this affects how long variables are kept in registers), for example numerical floatingpoint values get computed with slightly different results. Finally, it affects code that carefully makes use of cancellation properties, like Residue
.
If the platform is not affected by the excess precision problem, this class becomes an empty class doing nothing.
Note that nothing can be done for the excess range of the exponent, which affects underflow and overflow cases, fortunately less frequent.
Note also that in the process of setting the correct precision, the rounding mode is also set to the nearest.
Moreover, some compilers provide a flag that performs this setting at the time of program startup. For example, GCC provides the option mpc64
since release 4.3 which does exactly this. Other compilers may have similar options.
Similarly, some thirdparty libraries may do the same thing as part of their startup process, and this is notably the case of LEDA (at least some versions of it). CGAL does not enforce this at startup as it would impact computations with long double performed by other codes in the same program.
Note that this property is notably required for proper functioning of the Residue
class that performs modular arithmetic using efficient floatingpoint operations.
Note concerning Visual C++ 64bit: due to a compiler bug, the stack unwinding process happening when an exception is thrown does not correctly execute the restoring operation when the Set_ieee_double_precision
object is destroyed. Therefore, for this configuration, some explicit code has to be added if you care about the state being restored.
CGAL::Protect_FPU_rounding<Protected>
CGAL::Residue
Related Functions  
(Note that these are not member functions.)  
void  force_ieee_double_precision () 
Sets the precision of operations on double to 53bits.  
Creation  
Set_ieee_double_precision ()  
Sets the precision of operations on double to 53bits.  
~Set_ieee_double_precision ()  
The precision and rounding modes are reset to the values they held before the constructor was called.  
CGAL::Set_ieee_double_precision::Set_ieee_double_precision  (  ) 
Sets the precision of operations on double to 53bits.
Note that the rounding mode is set to the nearest in the same process.

related 
Sets the precision of operations on double to 53bits.
Note that the rounding mode is set to the nearest in the same process.
The function does the same thing as the default constructor of Set_ieee_double_precision
except that it does not perform the save and restore of the previous state.