作者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