如何使用字符串中的 1024 位数字初始化 gmp 中的 mpz_t?
我想用一个非常大的值(例如 1024 位大整数)初始化 gmp 中的 mpz_t 变量。我怎样才能这样做呢?我是gmp新手。任何帮助将不胜感激。
I want to initialize a mpz_t
variable in gmp with a very large value like a 1024 bit large integer. How can I do so ? I am new to gmp. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
mpz_import
。例如:Use
mpz_import
. For example:要从 C++ 中的字符串初始化 GMP 整数,您可以使用 libgmp++ 并直接使用构造函数:
如果您仍然需要原始 mpz_t 类型,请说 n。 get_mpz_t()。
在 C 语言中,您必须这样拼写:
请参阅文档了解初始化整数的更多方法。
To initialize a GMP integer from a string in C++, you can use
libgmp++
and directly use a constructor:If you still need the raw
mpz_t
type, sayn.get_mpz_t()
.In C, you have to spell it out like this:
See the documentation for further ways to initialize integers.