#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double PI = 3.14159265358979612;
const double PP = 0.14159265358979612;
const float ss = 3.1415f;
const float aa = 0.1415926535f;
const float bb = 3.1415926535f;
const float cc = 33.1415926535f;
cout<<"==========float output================"<<endl;
cout //<< setprecision( 20 )
//<< setiosflags(ios::fixed | ios::showpoint )
<< PI << endl;
cout<< PP <<endl;
cout << ss << endl;
cout << aa <<" "<< bb <<" "<< cc <<endl;
cout<<"==========printf output================"<<endl;
printf("%f\n%f\n", PI, PP);
printf("%f\n%f\n", aa, cc);
return 0;
}
==========float output================//windows 默认以float数据类型输出。。。对于float 数据类型,有效位(从左到右第一个非零数开始数)数是6位
3.14159
0.141593
3.1415
0.141593 3.14159 33.1416
==========printf output================// %f 默认是输出小数点后6位,不是有效位数
3.141593
0.141593
0.141593
33.141594
Press any key to continue