重複の可能性:
浮動小数点精度
私が行うと.Itは次のcout<<8.0
ように印刷され8
ます.How to Print in the output console of c++の小数点以下のゼロ全体を、8.00000000
このcout<<setprecision(5)<<(double)8.0;
まま印刷しようとしたように8
fixed
マニピュレータを使用する
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout << fixed << setprecision(6) << (double)8 << "\n";
return 0;
}
cout を使用して double 値を完全な精度で出力するにはどうすればよいですか? を参照してください。
cout.precision(15);
cout << fixed << 8.0;