作者popo4231 (小泰)
看板EE_DSnP
标题[问题] 请大家看看
时间Tue Oct 9 21:22:11 2007
#include<iostream>
using namespace std;
#include<iomanip>
using namespace std;
int main()
{
double d = 1.234567891234;
cout<<fixed<<setprecision(16)<<d<<endl;
system("pause");
return 0;
}
输出:1.2345678912339999
请按任意键继续 . . .
为什麽会这样呢?
如果改成showpoint:
#include<iostream>
using namespace std;
#include<iomanip>
using namespace std;
int main()
{
double d = 1.234567891234;
cout<<showpoint<<setprecision(16)<<d<<endl;
system("pause");
return 0;
}
输出:
1.234567891234000
请按任意键继续 . . .
超奇怪的
可以帮忙解答吗
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.241.177
1F:推 flarehunter:setprecision(16)是输出16位精准的意思吗? 10/11 22:22
2F:推 ric2k1:Yes, you can take a look @ lecture note #3, page 60. 10/11 23:12