这可能是 这个问题 的重复,但是我感觉它没有得到正确的答案。请注意:
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
float p = 1.00;
cout << showpoint << setprecision(3) << p << endl;
}
输出:1.00
现在,如果我们将那行代码改为:
cout << fixed << showpoint << setprecision(3) << p << endl;
我们得到:
1.000
如果我们使用“相反”于固定的东西,我们会得到完全不同的结果: cout << scientific << showpoint << setprecision(3) << p << endl;
输出:1.000e+00
在 fixed
被设置后,我如何回到第一个版本的行为?