可用double转成整型,用float转成整型有精度损失,因为float精确6位,double精确16位,要求只要输出10位那么double型就够用了。
#include
using namespace std;
int main()
{
float a = 3.14159265358979323e+10;
double b = 3.14159265358979323e+10;
cout << c1 << endl; // float 精确位6
cout << c2 << endl; // doble 精确位16
}