可以将2.1834e+14转换为实数

Its possible to convert 2.1834e+14 to the real extensive number

本文关键字:转换 实数 1834e+14      更新时间:2023-10-16

我做了这个程序:

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {
    long double ln=0, nc=0;
    char choice;
    cout<<"Number1: "; cin>>ln;
    cout<<"Number2: "; cin>>nc;
    cout<<"Result: "<<pow(ln,nc);
    cout<<"Continue?(y/n): ";
    cin>>choice;
    if(choice=='y') {
        main();
    }
    return 0;
}

数字,如果要长出现,例如,像这样的"2.1834e+14"。有办法把它转化为实数吗?

如果您不希望计数显示科学记数法,您可能应该查找std::fixed流操作。

您还可以查找必须包含此库的setprecision(n)

#include <iomanip>

也有一些库,如GNU MP,用于存储非常大的数字。例如:- 2^1000需要一个1001位的整数来表示而不丢失精度。