c++如何输出一个超过10位的整数?

2025-05-17 01:28:31
推荐回答(1个)
回答(1):

可用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

}