Writing numbers to a file with more precision - C++ -
Writing numbers to a file with more precision - C++ -
i wrote parameters (all of type double) file utilize in performing complex computations. write parameters files so:
refstatsout << "someparam:" << value_of_type_double << endl; refstatsout ofstreamparameter. there 4 such parameters, each of type double. see written file different actual value (in terms of loss of precision). example, if value_of_type_double had value -28.07270379934792, see written in file -28.0727.
also, 1 time these stats have been computed , written run different programs utilize these statistics. files read , values stored std::strings , converted double via atof functions. results in values have shown above , ruins computations farther down.
my question this: 1. there way increment resolution 1 can write values (of type double , like) file not lose precision? 2. problem of std::string double conversion atof? if so, other function utilize solve this?
p.s: please allow me know in case of details in question not clear. seek update them , provide more details.
you can utilize setprecision function.
c++ file-io precision
Comments
Post a Comment