[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.11.1 Conversion to floating-point numbers
The type float_format_t
describes a floating-point format.
float_format_t float_format (uintE n)
-
Returns the smallest float format which guarantees at least
n
decimal digits in the mantissa (after the decimal point). float_format_t float_format (const cl_F& x)
Returns the floating point format of
x
.float_format_t default_float_format
-
Global variable: the default float format used when converting rational numbers to floats.
To convert a real number to a float, each of the types
cl_R
, cl_F
, cl_I
, cl_RA
,
int
, unsigned int
, float
, double
defines the following operations:
cl_F cl_float (const type&x, float_format_t f)
-
Returns
x
as a float of formatf
. cl_F cl_float (const type&x, const cl_F& y)
Returns
x
in the float format ofy
.cl_F cl_float (const type&x)
Returns
x
as a float of formatdefault_float_format
if it is an exact number, orx
itself if it is already a float.
Of course, converting a number to a float can lose precision.
Every floating-point format has some characteristic numbers:
cl_F most_positive_float (float_format_t f)
-
Returns the largest (most positive) floating point number in float format
f
. cl_F most_negative_float (float_format_t f)
-
Returns the smallest (most negative) floating point number in float format
f
. cl_F least_positive_float (float_format_t f)
-
Returns the least positive floating point number (i.e. > 0 but closest to 0) in float format
f
. cl_F least_negative_float (float_format_t f)
-
Returns the least negative floating point number (i.e. < 0 but closest to 0) in float format
f
. cl_F float_epsilon (float_format_t f)
-
Returns the smallest floating point number e > 0 such that
1+e != 1
. cl_F float_negative_epsilon (float_format_t f)
-
Returns the smallest floating point number e > 0 such that
1-e != 1
.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 27, 2013 using texi2html 5.0.