#include<iostream>
#include<iomanip> //此库为代码最后一行快捷设置数据格式需要用的的库 
#include<math.h>


using namespace std;


#define PI atan(1.0) * 4


int main(){

cout << "原始数据:" << PI << endl;
cout.precision(2);
cout << "设置有效数位后的数据:" << PI << endl;
cout.setf(ios::fixed);
    cout << "设置小数点后有效数位的数据" << PI << endl;
    cout << "输出格式已绑定后的数据" << PI << endl;
    cout.unsetf(ios::fixed); 
    cout.precision(6);
    cout << "输出格式已恢复默认后的数据" << PI << endl;
    cout << "快捷设置输出格式后的数据:" << fixed << setprecision(2) << PI << endl;
    

    return 0;


}


C/C++ 数据精确度的设置

相关文章:

  • 2022-12-23
  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-11-30
  • 2021-09-21
  • 2021-11-30
  • 2021-06-01
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案