需要包含的头文件
#include <iomanip>
Program:
Result:
Summary:
setprecision(n)设置精度为n,
当没有设置fixed时,这个数的精度为n,设置fixed时,小数点后的数字精度为n,小数点前没有限制。
关于输出的精度控制见《C++ Primer(3rd edition)》chapter20- iostream library
需要包含的头文件
#include <iomanip>
Program:
Result:
Summary:
setprecision(n)设置精度为n,
当没有设置fixed时,这个数的精度为n,设置fixed时,小数点后的数字精度为n,小数点前没有限制。
关于输出的精度控制见《C++ Primer(3rd edition)》chapter20- iostream library
相关文章: