我想我什么都没有。cpp_int
中的boost::multiprecision
类是否应该容纳想要的整数?
假设我要存储以下荒谬的大整数。我应该怎么做?
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
cpp_int n = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
以下代码返回 error: integer literal is too large to be represented in any integer type
最佳答案
如文档中所述,您需要使用字符串进行构造:
cpp_int n{"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"};
参见https://www.boost.org/doc/libs/1_74_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html
关于c++ - 带 boost 的大整数:太大而无法以任何整数类型表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64793676/