c++中浮点数精度设置

1、包含头文件<iomanip>,附注manip是manipulator,操控的简写。

2、第一种写法:

cout<<setiosflags(ios::fixed)<<setprecision(2);

第二种写法:

cout.setf(ios::fixed);
cout<<setprecision(2);

第三种写法:

cout<<fixed<<setprecision(2);

 

posted @ 2019-02-14 15:59  立体风  阅读(3913)  评论(0编辑  收藏  举报