#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
double a = 123.456789012345;
cout << a << endl;
cout << setprecision(9) << a << endl;
cout << setprecision(6);
cout << setiosflags(ios::fixed);
cout << setiosflags(ios::fixed) << setprecision(8) << a << endl;
cout << setiosflags(ios::scientific) << a << endl;
cout << setiosflags(ios::scientific) << setprecision(4) << a << endl;
}
用vs2019输出以下结果:
123.457
123.456789
123.45678901
0x1.edd3c07fb4c69p+6
0x1.edd3c07fb4c69p+6
用Dev C++输出下面这个结果:
123.457
123.456789
123.45678901
123.45679
123.5
书上的标准答案是第二个,怎么回事?求大佬回答