No subject

Sat Oct 15 01:12:28 CEST 2005

    4.1.3 Constructing floating-point numbers

    `cl_F' objects with low precision are most easily constructed from C
    `float' and `double'. See *Note 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 *Note Internal and printed representation::.)
            cl_F e =
    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 *Note 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));

It appears like you are still totally confused about the relation between
decimal and binary representation.  Please do have a close look at the
paper by David Goldberg that Bruno Haible has recommended in an earlier

What do you think a close approximation of 1/10 decimal in binary float
is, provided you have 300 binary digits?  Hint: the mantissa doesn't end
in all zeros.  Rather in 11001100110011001100....

Since CLN neither does BCD nor is psychic, all decimal numbers must be
approximated for a binary representation.  Now, since your input was not
an (exact) rational number, but rather some float with limited precision,
CLN did approximate as much as was reasonable.  But not more.

Hasta la proxima
Richard B. Kreckel

More information about the CLN-list mailing list