print multi-precision floating number in scientific notation
Hi CLN developers, Sorry for frequently asking questions. I have checked manual and searched mailing list for full example, but nothing inside. Moreover, I only familiar with C... Question: How to use `print_float()` to print multi-precision floating number in scientific notation on terminal? below is the full code I have ever tried, but it always gives me compilation error. thanks. #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 ; }
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 ; }
participants (2)
-
Po-Hsun Tseng
-
Richard B. Kreckel