| |
Declaration of a variable.
| |
| |
Declaration and initialization.
| |
| |
Declaration and initialization with a small integer constant
, . 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.
|
|
| Assignment. |
|
| |
Not all values of a number type need be valid. The routine CGAL_is_valid checks this. For example, an expression like nt(0)/nt(0) can result in an invalid number. Routines often have as a precondition that all numerical values are valid. | ||
|
| |
When two large doubles are multiplied, the result may not fit in a NT. Some number types (the standard float and double type when they conform to standards) have a way to represent a too big value as infinity. CGAL_is_finite implies CGAL_is_valid. | ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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. | ||
|
| Division by zero need not be defined. It may result in a runtime error, an invalid value, a valid value or anything else. This basically means that the library tests for zero whenever it does a division. |
The previous section listed all the required functionality. For the user of a number type it is handy to have a larger set of operations available.
#include <CGAL/number_utils.h>
|
| |
returns the smaller of the two values. | ||
|
| |
returns the larger of the two values. | ||
|
| returns the absolute value. |
|
| |
returns the sign: -1, 0, or . | ||
|
| |
|
| |
|
| |
|
| |
| ||
|
Those routines are implemented using the required operations from the previous section. They are defined by means of templates, so you do not have to supply all those operations when you write a new number type.
For the number types bool, int, and double there is the random numbers generator CGAL_Random.