How can I define a constant width of double numbers in an output file?
I use setprecision and scientific, but when there is a negative number the minus sign needs on space extra.
I would like a solution that one of the zeros is deleted when it is a negative numer or similar.
1 2 3 4
|
std::ofstream resultFile("Result.dat");
resultFile << std::setprecision(NUMBER_PRECISION) << std::scientific << Data.at(it_row) << " ";
|
Output:
15 digits 15 digits 16 digits
1.04217000e+003 1.55950000e+001 -7.32260000e+002
1.08319000e+003 1.38020000e+001 -1.23905000e+003
1.11182000e+003 1.25860000e+001 -1.66787000e+003
1.13294000e+003 1.17060000e+001 -2.03544000e+003
1.14922000e+003 1.10390000e+001 -2.35399000e+003
1.16218000e+003 1.05160000e+001 -2.63272000e+003
1.17278000e+003 1.00950000e+001 -2.87867000e+003
1.18162000e+003 9.74740000e+000 -3.09728000e+003
1.18913000e+003 9.45650000e+000 -3.29288000e+003
1.19559000e+003 9.20910000e+000 -3.46893000e+003