c++ std::stream double values no scientific and no fixed count of decimals
问题 The following code will print value of a and b: double a = 3.0, b=1231231231233.0123456; cout.setf(std::ios::fixed); cout.unsetf(std::ios::scientific); cout << a << endl << b << endl The output is: 3.000000 1231231231233.012451 You can see that a is outputed with fixed 6 count of decimals. But I want the output like this: 3 1231231231233.012451 How can i set flags only once, and output the above result. 回答1: The stream inserts 0 s following the double because the stream's default precision