[CLN-list] print multi-precision floating number in scientific notation
Richard B. Kreckel
kreckel at in.terlu.de
Mon Feb 10 10:23:06 CET 2020
Hi,
You should first create the desired cl_print_flags object and then pass
it as reference to the print_float function, like this:
cl_print_flags flags;
flags.float_readably = true;
print_float(std::cout, flags, x[i]);
Note also that stdout is not a C++ stream. I've replaced it with cout.
-richy.
--
Richard B. Kreckel
<https://in.terlu.de/~kreckel/>
On 10.02.20 05:38, Po-Hsun Tseng wrote:
> #include <cln/io.h>
> #include <cln/float.h>
> #include <cln/float_io.h>
>
>
> using namespace cln;
>
> int main( ) {
>
> int N = 10;
>
> cl_F x[N];
>
> for (int i=0 ;i<N;i++) x[i] =
> "0.333333333333333333333333333333333333333333333333333333333333";
>
> // cl_print_flags.float_readably = true;
>
> for (int i=0 ;i<N;i++) print_float(stdout,
> cl_print_flags.float_readably, x[i]);
>
> return 0 ;
> }
More information about the CLN-list
mailing list