设置精度为双重
答
你会想要使用以下格式。
cout << setprecision(# of places past decimal) << fixed << varName << endl;
固定输入输出操纵器是告诉它,你正在设置小数点后位数的精度。
请显示代码。 – 2012-07-12 02:02:35
[std :: fixed](http://en.cppreference.com/w/cpp/io/manip/fixed)和[std :: setprecision](http://en.cppreference.com/w/cpp/ io/manip/setprecision)是有用的。 – chris 2012-07-12 02:03:11
请注意,在内部您不要设置浮点类型的精度。您将显示的数字格式化为两个小数点。 – 2012-07-12 02:18:12