C语言中的大整数?

发布于 2024-07-14 01:35:12 字数 143 浏览 6 评论 0原文

在 C 中处理大量数字的最简单方法是什么? 我需要将值存储在区域 1000^900 中,或者以更易于理解的形式 10^2700 存储。

有谁知道一个简单的方法来做到这一点? 任何帮助将不胜感激!

What is the easiest way to handle huge numbers in C? I need to store values in the Area 1000^900, or in more human readable form 10^2700.

Does anybody know of an easy way to do that? Any help would really be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心欲静而疯不止 2024-07-21 01:35:13

有许多库可以处理大量数据。 您需要整数或浮点运算吗?

您可以查看 Python 中内置的用于该任务的代码。

您可以查看 Perl 的扩展来完成该任务。

您可以查看 OpenSSL 中的代码来完成该任务。

您可以查看 GNU MP(多精度)库 - 正如 kmkaplan 所提到的。

There are a number of libraries for handling huge numbers around. Do you need integer or floating point arithmetic?

You could look at the code built into Python for the task.

You could look at the extensions for Perl for the task.

You could look at the code in OpenSSL for the task.

You could look at the GNU MP (multi-precision) library - as mentioned by kmkaplan.

千纸鹤 2024-07-21 01:35:12

使用 libgmp

GMP 是一个用于任意精度算术的免费库,可对有符号整数、有理数和浮点数进行运算。 除了 GMP 运行的机器中的可用内存暗示的精度之外,精度没有实际限制......

自版本 6 起,GMP 在双重许可证下分发,GNU LGPL v3GNU GPL v2...

GMP 的主要目标平台是 Unix 类型的系统,例如 GNU/Linux、Solaris、HP-UX、Mac OS X/Darwin、BSD、AIX 等。此外,它还可以在 32 位 Windows 上运行和 64 位模式...

Use libgmp:

GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on...

Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2...

GMP's main target platforms are Unix-type systems, such as GNU/Linux, Solaris, HP-UX, Mac OS X/Darwin, BSD, AIX, etc. It also is known to work on Windows in both 32-bit and 64-bit mode...

风筝在阴天搁浅。 2024-07-21 01:35:12

有一些库可以帮助您做到这一点(任意精度数学):

其他人。 假设这与工作无关(即,您这样做是为了好玩,或者是一种爱好,或者只是一个学习东西的机会),那么为任意精度数学编写一个库是一个相对有趣的项目。 但是,如果您需要绝对依赖它并且对具体细节不感兴趣,则只需使用库即可。

There are a few libraries to help you do this (arbitrary precision mathematics):

Assuming this isn't work related (ie you're doing it for fun or its a hobby or just an oportunity to learn something), coding up a library for arbitrary precision maths is a relatively interesting project. But if you need to absolutely rely on it and aren't interested in the nuts and bolts just use a library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文