CEO*_*ico 1 c++ floating-point
我们可以使用高达10 ^ 308的大数字.如何使用双倍计算11 ^ 105?
(11 ^ 105)的答案是:22193813979407164354224423199022080924541468040973950575246733562521125229836087036788826138225193142654907051
是否有可能得到11 ^ 105的正确结果?据我所知,双倍可以处理10 ^ 308,这比11 ^ 105大得多.我知道这段代码错了:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double n, p, x;
cin >> n >> p;
//scanf("%lf %lf", &n,&p);
x = exp(log((double)n)*p);
//printf("%lf\n", x);
cout << x <<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
谢谢.