@code{e} to 40 decimal places, first construct 1.0 to 40 decimal places
and then apply the exponential function:
@example
- cl_float_format_t precision = cl_float_format(40);
+ float_format_t precision = float_format(40);
cl_F e = exp(cl_float(1,precision));
@end example
The constant e = exp(1) = 2.71828@dots{} is returned by the following functions:
@table @code
-@item cl_F exp1 (cl_float_format_t f)
+@item cl_F exp1 (float_format_t f)
@cindex @code{exp1 ()}
Returns e as a float of format @code{f}.
Archimedes' constant pi = 3.14@dots{} is returned by the following functions:
@table @code
-@item cl_F pi (cl_float_format_t f)
+@item cl_F pi (float_format_t f)
@cindex @code{pi ()}
Returns pi as a float of format @code{f}.
Euler's constant C = 0.577@dots{} is returned by the following functions:
@table @code
-@item cl_F eulerconst (cl_float_format_t f)
+@item cl_F eulerconst (float_format_t f)
@cindex @code{eulerconst ()}
Returns Euler's constant as a float of format @code{f}.
@cindex Catalan's constant
@table @code
-@item cl_F catalanconst (cl_float_format_t f)
+@item cl_F catalanconst (float_format_t f)
@cindex @code{catalanconst ()}
Returns Catalan's constant as a float of format @code{f}.
following functions:
@table @code
-@item cl_F zeta (int s, cl_float_format_t f)
+@item cl_F zeta (int s, float_format_t f)
@cindex @code{zeta ()}
Returns Riemann's zeta function at @code{s} as a float of format @code{f}.
@subsection Conversion to floating-point numbers
-The type @code{cl_float_format_t} describes a floating-point format.
-@cindex @code{cl_float_format_t}
+The type @code{float_format_t} describes a floating-point format.
+@cindex @code{float_format_t}
@table @code
-@item cl_float_format_t cl_float_format (uintL n)
-@cindex @code{cl_float_format ()}
+@item float_format_t float_format (uintL n)
+@cindex @code{float_format ()}
Returns the smallest float format which guarantees at least @code{n}
decimal digits in the mantissa (after the decimal point).
-@item cl_float_format_t cl_float_format (const cl_F& x)
+@item float_format_t float_format (const cl_F& x)
Returns the floating point format of @code{x}.
-@item cl_float_format_t default_float_format
+@item float_format_t default_float_format
@cindex @code{default_float_format}
Global variable: the default float format used when converting rational numbers
to floats.
defines the following operations:
@table @code
-@item cl_F cl_float (const @var{type}&x, cl_float_format_t f)
+@item cl_F cl_float (const @var{type}&x, float_format_t f)
@cindex @code{cl_float ()}
Returns @code{x} as a float of format @code{f}.
@item cl_F cl_float (const @var{type}&x, const cl_F& y)
Every floating-point format has some characteristic numbers:
@table @code
-@item cl_F most_positive_float (cl_float_format_t f)
+@item cl_F most_positive_float (float_format_t f)
@cindex @code{most_positive_float ()}
Returns the largest (most positive) floating point number in float format @code{f}.
-@item cl_F most_negative_float (cl_float_format_t f)
+@item cl_F most_negative_float (float_format_t f)
@cindex @code{most_negative_float ()}
Returns the smallest (most negative) floating point number in float format @code{f}.
-@item cl_F least_positive_float (cl_float_format_t f)
+@item cl_F least_positive_float (float_format_t f)
@cindex @code{least_positive_float ()}
Returns the least positive floating point number (i.e. > 0 but closest to 0)
in float format @code{f}.
-@item cl_F least_negative_float (cl_float_format_t f)
+@item cl_F least_negative_float (float_format_t f)
@cindex @code{least_negative_float ()}
Returns the least negative floating point number (i.e. < 0 but closest to 0)
in float format @code{f}.
-@item cl_F float_epsilon (cl_float_format_t f)
+@item cl_F float_epsilon (float_format_t f)
@cindex @code{float_epsilon ()}
Returns the smallest floating point number e > 0 such that @code{1+e != 1}.
-@item cl_F float_negative_epsilon (cl_float_format_t f)
+@item cl_F float_negative_epsilon (float_format_t f)
@cindex @code{float_negative_epsilon ()}
Returns the smallest floating point number e > 0 such that @code{1-e != 1}.
@end table
or @samp{e}, which denotes a default float format. The precision specifying
suffix has the syntax _@var{prec} where @var{prec} denotes the number of
valid mantissa digits (in decimal, excluding leading zeroes), cf. also
-function @samp{cl_float_format}.
+function @samp{float_format}.
@item Complex numbers
External representation:
@item unsigned int rational_base
The base in which rational numbers are read.
-@item cl_float_format_t float_flags.default_float_format
+@item float_format_t float_flags.default_float_format
The float format used when reading floats with exponent marker @samp{e}.
-@item cl_float_format_t float_flags.default_lfloat_format
+@item float_format_t float_flags.default_lfloat_format
The float format used when reading floats with exponent marker @samp{l}.
@item cl_boolean float_flags.mantissa_dependent_float_format
If this flag is true, type specific exponent markers have precedence over 'E'.
Default is false.
-@item cl_float_format_t default_float_format
+@item float_format_t default_float_format
Floating point numbers of this format will be printed using the 'E' exponent
-marker. Default is @code{cl_float_format_ffloat}.
+marker. Default is @code{float_format_ffloat}.
@item cl_boolean complex_readably
If this flag is true, complex numbers will be printed using the Common Lisp
const cl_I fibonacci (int n)
@{
// Need a precision of ((1+sqrt(5))/2)^-n.
- cl_float_format_t prec = cl_float_format((int)(0.208987641*n+5));
+ float_format_t prec = float_format((int)(0.208987641*n+5));
cl_R sqrt5 = sqrt(cl_float(5,prec));
cl_R phi = (1+sqrt5)/2;
return round1( expt(phi,n)/sqrt5 );
The include file @code{<cln/integer.h>} is necessary because the type
@code{cl_I} is used in the function, and the include file @code{<cln/real.h>}
is needed for the type @code{cl_R} and the floating point number functions.
-The order of the include files does not matter. In order not to write out
-@code{cln::}@var{foo} we can safely import the whole namespace @code{cln}.
+The order of the include files does not matter. In order not to write
+out @code{cln::}@var{foo} in this simple example we can safely import
+the whole namespace @code{cln}.
Then comes the function declaration. The argument is an @code{int}, the
result an integer. The return type is defined as @samp{const cl_I}, not