哪些 bignum 库可与 D 配合使用?
我需要一个 bignum 库来表示大整数。 D 编程语言有哪些选择?例如,是否存在 GMP 绑定?
更新:
我正在尝试使用内置的 BigInt,如下所述,但它似乎不适用于 GDC。
import std.bigint;
import std.stdio;
void main()
{
BigInt n = "123";
writefln(n);
}
当我尝试使用 gdc main.d 编译此代码时,我被告知找不到 bigint.d。 gdc 只实现了一些库还是我做错了什么?
I'm in need of a bignum library for representing large integers. What options do I have with the D programming language? Are there, for instance, GMP bindings?
Update:
I'm trying to use the inbuilt BigInt as described below but it appears it's not available with the GDC.
import std.bigint;
import std.stdio;
void main()
{
BigInt n = "123";
writefln(n);
}
When I try to compile this code with gdc main.d
I'm told it can't find bigint.d. Does gdc only implement some of the library or am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要寻找的是大整数类型,那么有
BigInt
在标准库中。另一方面,如果您专门希望使用 GMP,那么您所要做的就是为您需要的 GMP 中的适当类型和函数进行extern(C)
声明,并且您可以直接从 D 调用它们。请查看此页面,了解有关如何进行操作的更多详细信息在D中使用C代码。If what you're looking for is a big integer type, then there's
BigInt
in the standard library. On the other hand, if you're specifically looking to use GMP, then all you have to do is haveextern(C)
declarations for the appropriate types and functions in GMP that you need, and you can call them directly from D. Check out out this page for more details on how to use C code in D.Paul Anderson 正在为标准库开发 BigFloat 抽象。
Paul Anderson is working on a BigFloat abstraction for the standard library.