确实很大的数字
首先,如果已经有这样的主题但我还没有找到,我深表歉意...我需要知道如何处理一个非常大的数字,例如 789^2346 的结果:
#include <iostream>
#include <cmath>
using namespace std;
int main () {
cout << pow(789,2346) << endl;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试 GNU MP Bignum Library 或 ttmath。此链接指向一些示例。它非常容易使用。
You could try the GNU MP Bignum Library or ttmath. This link point to some samples. It is very easy to use.
你需要一个“大数字”库。一个流行的选择是 GNU 的多精度算术库,它具有 C 接口。我也来了一段时间了。另一个针对 C++ 的库是 大整数库。
我确信某处有一个 bignum 库列表,但我找不到它。您可以浏览一个标签。
You need a "big number" library. A popular choice is GNU's Multiple Precision Arithmetic Library, which has a C interface. I's also been around for a while. Another one, for C++, is Big Integer Library.
I'm sure there is a list of bignum libraries on SO somewhere, but I cannot find it. There is a tag you could stroll through.
您可以考虑 C++ 的 NTL(数论库) - http://www.shoup.net/ntl/< /a> .它非常容易使用。
如果你可以放宽 C++ 的要求,Perl 和 Python 本身就支持大整数。 PHP 通过 bcmath 或 gmp 扩展支持。
You can consider NTL (Number Theory Library) for C++ - http://www.shoup.net/ntl/ . It's very easy to use.
If you can relax C++ requirement, Perl and Python support big integers natively. PHP supports via bcmath or gmp extensions.