看板 EE_DSnP 關於我們 聯絡資訊
#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
flarehunter:setprecision(16)是輸出16位精準的意思嗎? 10/11 22:22
ric2k1:Yes, you can take a look @ lecture note #3, page 60. 10/11 23:12