manpagez: man pages & more
info cln
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.3 Constructing floating-point numbers

cl_F objects with low precision are most easily constructed from C ‘float’ and ‘double’. See Conversions.

To construct a cl_F with high precision, you can use the conversion from ‘const char *’, but you have to specify the desired precision within the string. (See Internal and printed representation.) Example:

   cl_F e = "0.271828182845904523536028747135266249775724709369996e+1_40";

will set ‘e’ to the given value, with a precision of 40 decimal digits.

The programmatic way to construct a cl_F with high precision is through the cl_float conversion function, see Conversion to floating-point numbers. For example, to compute e to 40 decimal places, first construct 1.0 to 40 decimal places and then apply the exponential function:

   float_format_t precision = float_format(40);
   cl_F e = exp(cl_float(1,precision));

This document was generated on August 27, 2013 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.