¿Cout Double or Float without additional 0?

Hi, im im working calculating stuff in files, input and output data, etc..., the question is the following: I output double numbers with:

myFIle << fixed << setprecision(10) << double;

The problem i got is that when a numer is like 193123.2 it prints like 193123.200000..., so finally, ¿how can i print it with any additional 0 that i need?.

Thx and Greetings.
Last edited on
If you don't want trailing zeroes, simply don't use std::fixed:

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <iomanip>

int main()
{
    double d1 = 193123.2;
    double d2 = 0.1931232;

    std::cout << std::setprecision(10) << d1 << '\n' << d2 << '\n';
}
193123.2
0.1931232

Topic archived. No new replies allowed.